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