2022-04-01 16:49:29 +02:00
|
|
|
program SwaggerPrimer;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
WinAPI.ShellAPI,
|
|
|
|
WinAPI.Windows,
|
|
|
|
{$ENDIF}
|
|
|
|
System.SysUtils,
|
2022-12-25 19:46:07 +01:00
|
|
|
MVCFramework,
|
2022-04-01 16:49:29 +02:00
|
|
|
MVCFramework.Logger,
|
|
|
|
MVCFramework.Commons,
|
2022-12-25 19:46:07 +01:00
|
|
|
MVCFramework.Signal,
|
2022-04-01 16:49:29 +02:00
|
|
|
Web.ReqMulti,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdContext,
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
MyControllerU in 'MyControllerU.pas',
|
|
|
|
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
|
|
|
|
EntitiesU in 'EntitiesU.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.MaxConnections := 0;
|
|
|
|
LServer.ListenQueue := 200;
|
2022-12-25 19:46:07 +01:00
|
|
|
LServer.Active := True;
|
2022-04-01 16:49:29 +02:00
|
|
|
|
2022-12-25 19:46:07 +01:00
|
|
|
Writeln('CTRL+C to shutdown the server');
|
|
|
|
WaitForTerminationSignal;
|
|
|
|
EnterInShutdownState;
|
2022-04-01 16:49:29 +02:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
IsMultiThread := True;
|
|
|
|
try
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
WebRequestHandlerProc.MaxConnections := 1024;
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
ShellExecute(0, PChar('open'), PChar('http://localhost:8080/swagger'), nil, nil, sw_show);
|
|
|
|
{$ENDIF}
|
|
|
|
RunServer(8080);
|
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|