mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
73 lines
2.0 KiB
ObjectPascal
73 lines
2.0 KiB
ObjectPascal
program HTMX_Sample;
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
uses
|
|
System.SysUtils,
|
|
MVCFramework,
|
|
MVCFramework.Logger,
|
|
MVCFramework.Commons,
|
|
MVCFramework.Signal,
|
|
Web.ReqMulti,
|
|
Web.WebReq,
|
|
Web.WebBroker,
|
|
IdContext,
|
|
IdHTTPWebBrokerBridge,
|
|
uConfig.Module in 'uConfig.Module.pas' {ConfigModule: TWebModule},
|
|
uBase.Controller in 'Controllers\uBase.Controller.pas',
|
|
uMovie.Controller in 'Controllers\uMovie.Controller.pas',
|
|
uData.Model in 'Classes\uData.Model.pas',
|
|
uServices in 'Classes\uServices.pas',
|
|
MVCFramework.HTMX in 'MVCFramework.HTMX.pas';
|
|
|
|
{$R *.res}
|
|
|
|
|
|
procedure RunServer(APort: Integer);
|
|
var
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
begin
|
|
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
try
|
|
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
|
LServer.DefaultPort := APort;
|
|
LServer.KeepAlive := True;
|
|
|
|
{ more info about MaxConnections
|
|
http://ww2.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=index.html }
|
|
LServer.MaxConnections := 0;
|
|
|
|
{ more info about ListenQueue
|
|
http://ww2.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=index.html }
|
|
LServer.ListenQueue := 200;
|
|
|
|
LServer.Active := True;
|
|
WriteLn('Listening on port ', APort);
|
|
Write('CTRL+C to shutdown the server');
|
|
WaitForTerminationSignal;
|
|
EnterInShutdownState;
|
|
LServer.Active := False;
|
|
finally
|
|
LServer.Free;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
IsMultiThread := True;
|
|
// DMVCFramework Specific Configuration
|
|
// When MVCSerializeNulls = True empty nullables and nil are serialized as json null.
|
|
// When MVCSerializeNulls = False empty nullables and nil are not serialized at all.
|
|
MVCSerializeNulls := True;
|
|
try
|
|
if WebRequestHandler <> nil then
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
WebRequestHandlerProc.MaxConnections := 1024;
|
|
RunServer(8080);
|
|
except
|
|
on E: Exception do
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
end;
|
|
end.
|