2015-04-01 17:01:23 +02:00
|
|
|
unit WebModuleUnit1;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2020-04-29 01:59:41 +02:00
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2015-04-01 17:01:23 +02:00
|
|
|
System.Classes,
|
|
|
|
Web.HTTPApp,
|
2017-03-30 21:22:54 +02:00
|
|
|
MVCFramework,
|
|
|
|
MVCFramework.Commons;
|
2015-04-01 17:01:23 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TWebModule1 = class(TWebModule)
|
|
|
|
procedure WebModuleCreate(Sender: TObject);
|
|
|
|
|
|
|
|
private
|
|
|
|
MVC: TMVCEngine;
|
|
|
|
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
WebModuleClass: TComponentClass = TWebModule1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
2016-12-01 15:24:56 +01:00
|
|
|
|
2020-04-29 01:59:41 +02:00
|
|
|
uses
|
|
|
|
AppControllerU,
|
|
|
|
System.Generics.Collections,
|
|
|
|
MVCFramework.Middleware.Authentication,
|
|
|
|
MVCFramework.Middleware.StaticFiles,
|
|
|
|
AuthenticationU;
|
2015-04-01 17:01:23 +02:00
|
|
|
|
|
|
|
procedure TWebModule1.WebModuleCreate(Sender: TObject);
|
|
|
|
begin
|
2020-05-11 23:39:43 +02:00
|
|
|
MVC := TMVCEngine.Create(Self,
|
|
|
|
procedure(Config: TMVCConfig)
|
|
|
|
begin
|
|
|
|
Config[TMVCConfigKey.SessionTimeout] := '30';
|
|
|
|
Config[TMVCConfigKey.DefaultContentType] := 'text/html';
|
|
|
|
end);
|
2016-12-01 15:24:56 +01:00
|
|
|
MVC
|
|
|
|
.AddController(TApp1MainController)
|
|
|
|
.AddController(TAdminController)
|
2020-04-29 01:59:41 +02:00
|
|
|
.AddMiddleware(TMVCBasicAuthenticationMiddleware.Create(TAuthenticationSample.Create))
|
|
|
|
.AddMiddleware(TMVCStaticFilesMiddleware.Create(
|
2020-05-11 23:39:43 +02:00
|
|
|
'/', { StaticFilesPath }
|
2020-08-13 17:40:02 +02:00
|
|
|
'..\..\www', { DocumentRoot }
|
|
|
|
'index.html',
|
|
|
|
False { not serving a SPA }
|
2020-04-29 01:59:41 +02:00
|
|
|
));
|
2015-04-01 17:01:23 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|