delphimvcframework/samples/jsonwebtokenplain/jwtplainserver.dpr

62 lines
1.6 KiB
ObjectPascal
Raw Normal View History

program jwtplainserver;
2019-12-01 20:55:31 +01:00
{$APPTYPE CONSOLE}
uses
System.SysUtils,
Winapi.Windows,
Winapi.ShellAPI,
Web.WebReq,
Web.WebBroker,
IdHTTPWebBrokerBridge,
MyControllerU in 'MyControllerU.pas',
2019-12-01 20:55:31 +01:00
MainWebModuleU in 'MainWebModuleU.pas', MVCFramework.Commons {MyWebModule: TWebModule};
{$R *.res}
2019-12-01 20:55:31 +01:00
procedure RunServer(APort: Integer);
var
LInputRecord: TInputRecord;
LEvent: DWord;
LHandle: THandle;
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln('** DMVCFramework Server **');
Writeln(Format('Starting HTTP Server on port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
2019-12-01 20:55:31 +01:00
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
LServer.DefaultPort := APort;
LServer.Active := True;
2019-12-01 20:55:31 +01:00
// ShellExecute(0, 'open', pChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOWMAXIMIZED);
Writeln('Press ESC to stop the server');
LHandle := GetStdHandle(STD_INPUT_HANDLE);
while True do
begin
Win32Check(ReadConsoleInput(LHandle, LInputRecord, 1, LEvent));
if (LInputRecord.EventType = KEY_EVENT) and
LInputRecord.Event.KeyEvent.bKeyDown and
(LInputRecord.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE) then
break;
end;
finally
LServer.Free;
end;
end;
begin
ReportMemoryLeaksOnShutdown := 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;
2019-12-01 20:55:31 +01:00
end.