mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Now "NoRouteFound" error returns the correct content-type
This commit is contained in:
parent
49bbce0959
commit
cc5789d56e
@ -34,6 +34,8 @@ type
|
|||||||
function GetSum(const A, B: Integer): Integer;
|
function GetSum(const A, B: Integer): Integer;
|
||||||
[MVCPath('/sumsasfloat/($A)/($B)')]
|
[MVCPath('/sumsasfloat/($A)/($B)')]
|
||||||
function GetSumAsFloat(const A, B: Extended): Extended;
|
function GetSumAsFloat(const A, B: Extended): Extended;
|
||||||
|
[MVCPath('/string/($A)/($B)')]
|
||||||
|
function GetConcatAsString(const A, B: String): String;
|
||||||
|
|
||||||
{ actions returning records }
|
{ actions returning records }
|
||||||
[MVCPath('/records/single')]
|
[MVCPath('/records/single')]
|
||||||
@ -258,6 +260,11 @@ begin
|
|||||||
Result := A + B;
|
Result := A + B;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMyController.GetConcatAsString(const A, B: String): String;
|
||||||
|
begin
|
||||||
|
Result := A + B;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMyController.GetWithCustomHeaders: TObjectList<TPerson>;
|
function TMyController.GetWithCustomHeaders: TObjectList<TPerson>;
|
||||||
begin
|
begin
|
||||||
Result := TObjectList<TPerson>.Create;
|
Result := TObjectList<TPerson>.Create;
|
||||||
|
@ -25,7 +25,7 @@ procedure RunServer(APort: Integer);
|
|||||||
var
|
var
|
||||||
LServer: TIdHTTPWebBrokerBridge;
|
LServer: TIdHTTPWebBrokerBridge;
|
||||||
begin
|
begin
|
||||||
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
LogI('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
||||||
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
||||||
try
|
try
|
||||||
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
||||||
@ -35,8 +35,8 @@ begin
|
|||||||
LServer.ListenQueue := dotEnv.Env('dmvc.indy.listen_queue', 500);
|
LServer.ListenQueue := dotEnv.Env('dmvc.indy.listen_queue', 500);
|
||||||
|
|
||||||
LServer.Active := True;
|
LServer.Active := True;
|
||||||
WriteLn('Listening on port ', APort);
|
LogI('Listening on port ' + APort.ToString);
|
||||||
Write('CTRL+C to shutdown the server');
|
LogI('CTRL+C to shutdown the server');
|
||||||
WaitForTerminationSignal;
|
WaitForTerminationSignal;
|
||||||
EnterInShutdownState;
|
EnterInShutdownState;
|
||||||
LServer.Active := False;
|
LServer.Active := False;
|
||||||
@ -47,7 +47,7 @@ end;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
{ Enable ReportMemoryLeaksOnShutdown during debug }
|
{ Enable ReportMemoryLeaksOnShutdown during debug }
|
||||||
// ReportMemoryLeaksOnShutdown := True;
|
ReportMemoryLeaksOnShutdown := True;
|
||||||
IsMultiThread := True;
|
IsMultiThread := True;
|
||||||
|
|
||||||
// DMVCFramework Specific Configuration
|
// DMVCFramework Specific Configuration
|
||||||
@ -78,6 +78,6 @@ begin
|
|||||||
RunServer(dotEnv.Env('dmvc.server.port', 8080));
|
RunServer(dotEnv.Env('dmvc.server.port', 8080));
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do
|
||||||
Writeln(E.ClassName, ': ', E.Message);
|
LogE(E.ClassName + ': ' + E.Message);
|
||||||
end;
|
end;
|
||||||
end.
|
end.
|
||||||
|
@ -44,7 +44,7 @@ uses
|
|||||||
procedure TApp1MainController.HelloWorld;
|
procedure TApp1MainController.HelloWorld;
|
||||||
begin
|
begin
|
||||||
Render('Hello World called with GET');
|
Render('Hello World called with GET');
|
||||||
if Context.Request.ThereIsRequestBody then
|
if Context.Request.HasBody then
|
||||||
Log('Body:' + Context.Request.Body);
|
Log('Body:' + Context.Request.Body);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -823,8 +823,8 @@ type
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Page calls GetRenderedView with sensible defaults.
|
/// Page calls GetRenderedView with sensible defaults.
|
||||||
/// Page method just concatenate -> commonheader_header_views + views + commonfooter_views
|
/// Page method with UseCommonHeadersAndFooters = True (default) concatenates
|
||||||
/// PageFragment ignore header and footer views
|
// commonheader_header_views + views + commonfooter_views
|
||||||
/// </summary>
|
/// </summary>
|
||||||
function Page(const AViewNames: TArray<string>; const JSONModel: TJSONObject; const UseCommonHeadersAndFooters: Boolean = True): string; overload; inline;
|
function Page(const AViewNames: TArray<string>; const JSONModel: TJSONObject; const UseCommonHeadersAndFooters: Boolean = True): string; overload; inline;
|
||||||
|
|
||||||
@ -2788,6 +2788,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
lContext.Response.StatusCode := http_status.NotFound;
|
lContext.Response.StatusCode := http_status.NotFound;
|
||||||
lContext.Response.ReasonString := 'Not Found';
|
lContext.Response.ReasonString := 'Not Found';
|
||||||
|
lContext.Response.SetContentStream(TStringStream.Create(), FConfigCache_DefaultContentType);
|
||||||
fOnRouterLog(lRouter, rlsRouteNotFound, lContext);
|
fOnRouterLog(lRouter, rlsRouteNotFound, lContext);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -27,7 +27,8 @@ uses
|
|||||||
Entities in '..\Several\Entities.pas',
|
Entities in '..\Several\Entities.pas',
|
||||||
EntitiesProcessors in '..\Several\EntitiesProcessors.pas',
|
EntitiesProcessors in '..\Several\EntitiesProcessors.pas',
|
||||||
MVCFramework.JSONRPC.Client in '..\..\..\sources\MVCFramework.JSONRPC.Client.pas',
|
MVCFramework.JSONRPC.Client in '..\..\..\sources\MVCFramework.JSONRPC.Client.pas',
|
||||||
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas';
|
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas',
|
||||||
|
MVCFramework.Serializer.Commons;
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ end;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
ReportMemoryLeaksOnShutdown := True;
|
ReportMemoryLeaksOnShutdown := True;
|
||||||
|
gLocalTimeStampAsUTC := False;
|
||||||
UseConsoleLogger := False;
|
UseConsoleLogger := False;
|
||||||
try
|
try
|
||||||
if WebRequestHandler <> nil then
|
if WebRequestHandler <> nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user