unit WebModuleU; interface uses System.SysUtils, System.Classes, Web.HTTPApp, MVCFramework; type TWebModule1 = class(TWebModule) procedure WebModuleCreate(Sender: TObject); procedure WebModuleDestroy(Sender: TObject); private FMVCEngine: TMVCEngine; { Private declarations } public { Public declarations } end; var WebModuleClass: TComponentClass = TWebModule1; implementation uses MVCFramework.View.Renderers.Mustache, WebSiteControllerU, System.IOUtils, MVCFramework.Commons, MVCFramework.Middleware.Redirect, MVCFramework.Middleware.StaticFiles; { %CLASSGROUP 'Vcl.Controls.TControl' } {$R *.dfm} procedure TWebModule1.WebModuleCreate(Sender: TObject); begin FMVCEngine := TMVCEngine.Create(Self, procedure(Config: TMVCConfig) begin Config.dotEnv := dotEnv; // session timeout (0 means session cookie) Config[TMVCConfigKey.SessionTimeout] := dotEnv.Env('dmvc.session_timeout', '0'); //default content-type Config[TMVCConfigKey.DefaultContentType] := dotEnv.Env('dmvc.default.content_type', TMVCMediaType.TEXT_HTML); //default content charset Config[TMVCConfigKey.DefaultContentCharset] := dotEnv.Env('dmvc.default.content_charset', TMVCConstants.DEFAULT_CONTENT_CHARSET); //unhandled actions are permitted? Config[TMVCConfigKey.AllowUnhandledAction] := dotEnv.Env('dmvc.allow_unhandled_actions', 'false'); //enables or not system controllers loading (available only from localhost requests) Config[TMVCConfigKey.LoadSystemControllers] := dotEnv.Env('dmvc.load_system_controllers', 'true'); //default view file extension Config[TMVCConfigKey.DefaultViewFileExtension] := dotEnv.Env('dmvc.default.view_file_extension', 'mustache'); //view path Config[TMVCConfigKey.ViewPath] := dotEnv.Env('dmvc.view_path', 'templates'); //use cache for server side views (use "false" in debug and "true" in production for faster performances Config[TMVCConfigKey.ViewCache] := dotEnv.Env('dmvc.view_cache', 'false'); //Max Record Count for automatic Entities CRUD Config[TMVCConfigKey.MaxEntitiesRecordCount] := dotEnv.Env('dmvc.max_entities_record_count', IntToStr(TMVCConstants.MAX_RECORD_COUNT)); //Enable Server Signature in response Config[TMVCConfigKey.ExposeServerSignature] := dotEnv.Env('dmvc.expose_server_signature', 'false'); //Enable X-Powered-By Header in response Config[TMVCConfigKey.ExposeXPoweredBy] := dotEnv.Env('dmvc.expose_x_powered_by', 'true'); // Max request size in bytes Config[TMVCConfigKey.MaxRequestSize] := dotEnv.Env('dmvc.max_request_size', IntToStr(TMVCConstants.DEFAULT_MAX_REQUEST_SIZE)); end) .AddController(TWebSiteController) .AddMiddleware(TMVCRedirectMiddleware.Create(['/'],'/people')) .SetViewEngine(TMVCMustacheViewEngine) end; procedure TWebModule1.WebModuleDestroy(Sender: TObject); begin FMVCEngine.Free; end; end.