delphimvcframework/samples/serversideviews/WebModuleU.pas

66 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2016-05-03 19:04:24 +02:00
unit WebModuleU;
interface
2016-11-27 23:17:20 +01:00
uses System.SysUtils, System.Classes, Web.HTTPApp, MVCFramework;
2016-05-03 19:04:24 +02:00
type
TWebModule1 = class(TWebModule)
procedure WebModuleCreate(Sender: TObject);
procedure WebModuleDestroy(Sender: TObject);
2016-05-03 19:04:24 +02:00
private
FMVCEngine: TMVCEngine;
2016-11-27 23:17:20 +01:00
{ Private declarations }
public
{ Public declarations }
2016-05-03 19:04:24 +02:00
end;
var
WebModuleClass: TComponentClass = TWebModule1;
implementation
2017-05-09 23:13:51 +02:00
uses
MVCFramework.View.Renderers.Mustache, WebSiteControllerU, MVCFramework.Commons;
2016-11-27 23:17:20 +01:00
2017-05-09 23:13:51 +02:00
{ %CLASSGROUP 'Vcl.Controls.TControl' }
2016-05-03 19:04:24 +02:00
2016-11-27 23:17:20 +01:00
{$R *.dfm}
2016-05-03 19:04:24 +02:00
procedure TWebModule1.WebModuleCreate(Sender: TObject);
begin
FMVCEngine := TMVCEngine.Create(Self,
2016-11-27 23:17:20 +01:00
procedure(Config: TMVCConfig)
begin
// enable static files
Config[TMVCConfigKey.DocumentRoot] :=
ExtractFilePath(GetModuleName(HInstance)) + '\www';
// session timeout (0 means session cookie)
Config[TMVCConfigKey.SessionTimeout] := '0';
// default content-type
Config[TMVCConfigKey.DefaultContentType] :=
TMVCConstants.DEFAULT_CONTENT_TYPE;
// default content charset
Config[TMVCConfigKey.DefaultContentCharset] :=
TMVCConstants.DEFAULT_CONTENT_CHARSET;
// unhandled actions are permitted?
Config[TMVCConfigKey.AllowUnhandledAction] := 'false';
// default view file extension
Config[TMVCConfigKey.DefaultViewFileExtension] := 'mustache';
// view path
Config[TMVCConfigKey.ViewPath] := 'templates';
// Enable Server Signature in response
Config[TMVCConfigKey.ExposeServerSignature] := 'true';
2017-05-09 23:13:51 +02:00
end)
.AddController(TWebSiteController)
.SetViewEngine(TMVCMustacheViewEngine);
2016-11-27 23:17:20 +01:00
2016-05-03 19:04:24 +02:00
end;
procedure TWebModule1.WebModuleDestroy(Sender: TObject);
begin
FMVCEngine.Free;
end;
2016-05-03 19:04:24 +02:00
end.