2016-06-23 15:18:33 +02:00
|
|
|
|
program TestServer;
|
2013-10-30 01:09:09 +01:00
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
2016-06-23 15:18:33 +02:00
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
|
|
|
|
Winapi.Windows,
|
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
|
Web.WebReq,
|
|
|
|
|
Web.WebBroker,
|
2016-09-30 11:44:11 +02:00
|
|
|
|
WebModuleUnit in 'WebModuleUnit.pas' {bas: TWebModule} ,
|
2013-10-30 01:09:09 +01:00
|
|
|
|
TestServerControllerU in 'TestServerControllerU.pas',
|
2013-12-05 16:19:01 +01:00
|
|
|
|
BusinessObjectsU in '..\..\samples\commons\BusinessObjectsU.pas',
|
2014-03-31 11:25:16 +02:00
|
|
|
|
TestServerControllerExceptionU in 'TestServerControllerExceptionU.pas',
|
2016-06-22 17:49:16 +02:00
|
|
|
|
SpeedMiddlewareU in 'SpeedMiddlewareU.pas',
|
|
|
|
|
MVCFramework in '..\..\sources\MVCFramework.pas',
|
|
|
|
|
MVCFramework.RESTAdapter in '..\..\sources\MVCFramework.RESTAdapter.pas',
|
|
|
|
|
MVCFramework.ApplicationSession in '..\..\sources\MVCFramework.ApplicationSession.pas',
|
|
|
|
|
MVCFramework.Commons in '..\..\sources\MVCFramework.Commons.pas',
|
|
|
|
|
MVCFramework.HMAC in '..\..\sources\MVCFramework.HMAC.pas',
|
|
|
|
|
MVCFramework.JWT in '..\..\sources\MVCFramework.JWT.pas',
|
|
|
|
|
MVCFramework.Logger in '..\..\sources\MVCFramework.Logger.pas',
|
|
|
|
|
MVCFramework.MessagingController in '..\..\sources\MVCFramework.MessagingController.pas',
|
2016-09-30 11:44:11 +02:00
|
|
|
|
MVCFramework.Middleware.Authentication
|
|
|
|
|
in '..\..\sources\MVCFramework.Middleware.Authentication.pas',
|
2016-06-22 17:49:16 +02:00
|
|
|
|
MVCFramework.Middleware.CORS in '..\..\sources\MVCFramework.Middleware.CORS.pas',
|
|
|
|
|
MVCFramework.Middleware.JWT in '..\..\sources\MVCFramework.Middleware.JWT.pas',
|
|
|
|
|
MVCFramework.Router in '..\..\sources\MVCFramework.Router.pas',
|
|
|
|
|
MVCFramework.SysControllers in '..\..\sources\MVCFramework.SysControllers.pas',
|
|
|
|
|
MVCFramework.Session in '..\..\sources\MVCFramework.Session.pas',
|
|
|
|
|
MVCFramework.Server in '..\..\sources\MVCFramework.Server.pas',
|
|
|
|
|
MVCFramework.Server.Impl in '..\..\sources\MVCFramework.Server.Impl.pas',
|
|
|
|
|
MVCFramework.View.Cache in '..\..\sources\MVCFramework.View.Cache.pas',
|
|
|
|
|
MVCFramework.View in '..\..\sources\MVCFramework.View.pas',
|
2016-09-30 11:44:11 +02:00
|
|
|
|
MVCFramework.RTTIUtils in '..\..\sources\MVCFramework.RTTIUtils.pas',
|
2016-09-18 12:02:24 +02:00
|
|
|
|
TestServerControllerPrivateU in 'TestServerControllerPrivateU.pas',
|
|
|
|
|
AuthHandlersU in 'AuthHandlersU.pas';
|
2013-10-30 01:09:09 +01:00
|
|
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
2016-06-23 15:18:33 +02:00
|
|
|
|
|
|
|
|
|
procedure Logo;
|
|
|
|
|
begin
|
|
|
|
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED or FOREGROUND_INTENSITY);
|
|
|
|
|
WriteLn(' ██████╗ ███╗ ███╗██╗ ██╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗');
|
|
|
|
|
WriteLn(' ██╔══██╗████╗ ████║██║ ██║██╔════╝ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗');
|
|
|
|
|
WriteLn(' ██║ ██║██╔████╔██║██║ ██║██║ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝');
|
|
|
|
|
WriteLn(' ██║ ██║██║╚██╔╝██║╚██╗ ██╔╝██║ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗');
|
|
|
|
|
WriteLn(' ██████╔╝██║ ╚═╝ ██║ ╚████╔╝ ╚██████╗ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║');
|
|
|
|
|
WriteLn(' ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝');
|
|
|
|
|
WriteLn(' ');
|
|
|
|
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE or FOREGROUND_GREEN or
|
|
|
|
|
FOREGROUND_RED);
|
|
|
|
|
end;
|
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
|
var
|
|
|
|
|
LInputRecord: TInputRecord;
|
|
|
|
|
LEvent: DWord;
|
|
|
|
|
LHandle: THandle;
|
|
|
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
|
|
|
begin
|
2016-06-23 15:18:33 +02:00
|
|
|
|
Logo;
|
|
|
|
|
WriteLn(Format('Starting HTTP Server or port %d', [APort]));
|
2013-10-30 01:09:09 +01:00
|
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
|
try
|
|
|
|
|
LServer.DefaultPort := APort;
|
|
|
|
|
LServer.Active := True;
|
2016-09-20 11:10:40 +02:00
|
|
|
|
{ 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;
|
2016-06-23 15:18:33 +02:00
|
|
|
|
WriteLn('Press ESC to stop the server');
|
2013-10-30 01:09:09 +01:00
|
|
|
|
LHandle := GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
|
while True do
|
|
|
|
|
begin
|
2016-04-03 22:35:27 +02:00
|
|
|
|
{$WARN SYMBOL_PLATFORM OFF}
|
2013-10-30 01:09:09 +01:00
|
|
|
|
Win32Check(ReadConsoleInput(LHandle, LInputRecord, 1, LEvent));
|
2016-04-03 22:35:27 +02:00
|
|
|
|
{$WARN SYMBOL_PLATFORM ON}
|
2013-10-30 01:09:09 +01:00
|
|
|
|
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
|
2014-04-10 13:56:23 +02:00
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
2013-10-30 01:09:09 +01:00
|
|
|
|
try
|
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
2014-02-24 10:20:34 +01:00
|
|
|
|
RunServer(9999);
|
2013-10-30 01:09:09 +01:00
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
2016-06-23 15:18:33 +02:00
|
|
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
2013-10-30 01:09:09 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end.
|