2017-03-01 21:40:57 +01:00
|
|
|
|
program TestServer;
|
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
|
Web.WebReq,
|
2020-05-25 15:12:46 +02:00
|
|
|
|
{$IFNDEF LINUX}
|
2017-04-24 00:19:53 +02:00
|
|
|
|
Winapi.Windows,
|
2020-05-25 15:12:46 +02:00
|
|
|
|
{$ENDIF }
|
2017-03-01 21:40:57 +01:00
|
|
|
|
Web.WebBroker,
|
|
|
|
|
MVCFramework.Commons,
|
2017-10-16 22:57:27 +02:00
|
|
|
|
MVCFramework.Console,
|
2020-05-25 15:12:46 +02:00
|
|
|
|
WebModuleUnit in 'WebModuleUnit.pas' {MainWebModule: TWebModule} ,
|
2017-03-01 21:40:57 +01:00
|
|
|
|
TestServerControllerU in 'TestServerControllerU.pas',
|
|
|
|
|
TestServerControllerExceptionU in 'TestServerControllerExceptionU.pas',
|
|
|
|
|
SpeedMiddlewareU in 'SpeedMiddlewareU.pas',
|
|
|
|
|
TestServerControllerPrivateU in 'TestServerControllerPrivateU.pas',
|
|
|
|
|
AuthHandlersU in 'AuthHandlersU.pas',
|
2017-06-22 16:18:58 +02:00
|
|
|
|
BusinessObjectsU in '..\..\..\samples\commons\BusinessObjectsU.pas',
|
2017-09-26 01:02:09 +02:00
|
|
|
|
MVCFramework in '..\..\..\sources\MVCFramework.pas',
|
|
|
|
|
TestServerControllerJSONRPCU in 'TestServerControllerJSONRPCU.pas',
|
2018-10-23 16:18:34 +02:00
|
|
|
|
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas',
|
2019-06-25 17:32:30 +02:00
|
|
|
|
RandomUtilsU in '..\..\..\samples\commons\RandomUtilsU.pas',
|
2020-05-25 15:12:46 +02:00
|
|
|
|
MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes
|
|
|
|
|
in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes.pas';
|
2017-03-01 21:40:57 +01:00
|
|
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
procedure Logo;
|
|
|
|
|
begin
|
2020-05-25 15:12:46 +02:00
|
|
|
|
ResetConsole();
|
2020-04-18 23:32:24 +02:00
|
|
|
|
Writeln;
|
2020-05-25 15:12:46 +02:00
|
|
|
|
TextBackground(Black);
|
|
|
|
|
TextColor(Red);
|
|
|
|
|
Writeln(' ██████╗ ███╗ ███╗██╗ ██╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗');
|
|
|
|
|
Writeln(' ██╔══██╗████╗ ████║██║ ██║██╔════╝ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗');
|
|
|
|
|
Writeln(' ██║ ██║██╔████╔██║██║ ██║██║ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝');
|
|
|
|
|
Writeln(' ██║ ██║██║╚██╔╝██║╚██╗ ██╔╝██║ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗');
|
|
|
|
|
Writeln(' ██████╔╝██║ ╚═╝ ██║ ╚████╔╝ ╚██████╗ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║');
|
|
|
|
|
Writeln(' ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝');
|
|
|
|
|
Writeln(' ');
|
|
|
|
|
TextColor(Yellow);
|
|
|
|
|
Writeln('DMVCFRAMEWORK VERSION: ', DMVCFRAMEWORK_VERSION);
|
|
|
|
|
TextColor(White);
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
|
var
|
|
|
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
|
|
|
begin
|
|
|
|
|
Logo;
|
2020-05-25 15:12:46 +02:00
|
|
|
|
Writeln(Format('Starting HTTP Server or port %d', [APort]));
|
2017-03-01 21:40:57 +01:00
|
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
|
try
|
2020-05-25 15:12:46 +02:00
|
|
|
|
LServer.OnParseAuthentication :=
|
|
|
|
|
TMVCParseAuthentication.OnParseAuthentication;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
LServer.DefaultPort := APort;
|
|
|
|
|
LServer.Active := True;
|
|
|
|
|
{ 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;
|
2020-05-25 15:12:46 +02:00
|
|
|
|
Writeln('Press RETURN to stop the server');
|
2017-04-14 16:43:31 +02:00
|
|
|
|
ReadLn;
|
2020-05-25 15:12:46 +02:00
|
|
|
|
Writeln('Server stopped');
|
|
|
|
|
ResetConsole();
|
2017-03-01 21:40:57 +01:00
|
|
|
|
finally
|
|
|
|
|
LServer.Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
|
try
|
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
|
RunServer(9999);
|
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
2020-05-25 15:12:46 +02:00
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
2020-05-02 17:06:59 +02:00
|
|
|
|
end;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
|
|
|
|
|
end.
|