2013-10-29 16:51:16 +01:00
|
|
|
unit MainWebModuleUnit;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2018-08-05 20:31:33 +02:00
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
System.Classes,
|
|
|
|
Web.HTTPApp,
|
|
|
|
MVCFramework;
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
type
|
|
|
|
Twm = class(TWebModule)
|
|
|
|
procedure WebModuleCreate(Sender: TObject);
|
|
|
|
|
|
|
|
private
|
|
|
|
MVCEngine: TMVCEngine;
|
|
|
|
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
WebModuleClass: TComponentClass = Twm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-08-05 20:31:33 +02:00
|
|
|
WineCellarAppControllerU,
|
|
|
|
MVCFramework.Commons,
|
2020-04-29 01:59:41 +02:00
|
|
|
MVCFramework.Middleware.StaticFiles,
|
2018-08-05 20:31:33 +02:00
|
|
|
System.IOUtils;
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
procedure Twm.WebModuleCreate(Sender: TObject);
|
|
|
|
begin
|
2021-02-17 00:04:58 +01:00
|
|
|
MVCEngine := TMVCEngine.Create(self,
|
|
|
|
procedure(Conf: TMVCConfig)
|
|
|
|
begin
|
|
|
|
// Conf.Value[tmvcconfigkey.PathPrefix] := '/dmvc';
|
|
|
|
end);
|
2013-10-29 16:51:16 +01:00
|
|
|
MVCEngine.AddController(TWineCellarApp);
|
2021-02-17 00:04:58 +01:00
|
|
|
if not IsLibrary then
|
|
|
|
begin
|
|
|
|
MVCEngine.AddMiddleware(TMVCStaticFilesMiddleware.Create('/app', { StaticFilesPath }
|
|
|
|
TPath.Combine(AppPath, '..\..\www'), { DocumentRoot }
|
|
|
|
'index.html' { IndexDocument - Before it was named fallbackresource }
|
|
|
|
));
|
|
|
|
end;
|
2013-10-29 16:51:16 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|