2020-04-29 17:53:29 +02:00
|
|
|
program middleware_staticfiles;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2022-12-25 19:33:23 +01:00
|
|
|
MVCFramework,
|
2020-04-29 17:53:29 +02:00
|
|
|
MVCFramework.Logger,
|
|
|
|
MVCFramework.Commons,
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
Winapi.Windows,
|
|
|
|
Winapi.ShellAPI,
|
|
|
|
{$ENDIF}
|
2022-12-25 19:33:23 +01:00
|
|
|
MVCFramework.Signal,
|
2020-04-29 17:53:29 +02:00
|
|
|
Web.ReqMulti,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdContext,
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
MainControllerU in 'MainControllerU.pas',
|
|
|
|
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
|
|
|
|
SPARedirectController in 'SPARedirectController.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;
|
|
|
|
|
|
|
|
{ more info about MaxConnections
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
|
|
|
|
LServer.MaxConnections := 0;
|
|
|
|
|
|
|
|
{ more info about ListenQueue
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
|
|
|
|
LServer.ListenQueue := 200;
|
|
|
|
|
|
|
|
{ Comment the next line to avoid the default browser startup }
|
|
|
|
{$IFDEF MSWINDOWS}
|
2020-09-11 18:14:28 +02:00
|
|
|
//ShellExecute(0, 'open', PChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOWMAXIMIZED);
|
2020-04-29 17:53:29 +02:00
|
|
|
{$ENDIF}
|
|
|
|
{ required if you use JWT middleware }
|
|
|
|
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
2022-12-25 19:33:23 +01:00
|
|
|
LServer.Active := True;
|
|
|
|
Writeln('CTRL+C to shutdown the server');
|
|
|
|
WaitForTerminationSignal;
|
|
|
|
EnterInShutdownState;
|
2020-04-29 17:53:29 +02:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
IsMultiThread := 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.
|