-
Notifications
You must be signed in to change notification settings - Fork 3
/
Server.WebModule.pas
56 lines (43 loc) · 1.14 KB
/
Server.WebModule.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(*
Copyright 2016, MARS-Curiosity - REST Library
Home: https://github.com/andrea-magni/MARS
*)
unit Server.WebModule;
{$I MARS.inc}
interface
uses System.SysUtils, System.Classes, Web.HTTPApp;
type
TServerWebModule = class(TWebModule)
procedure ServerWebModuleDefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModuleClass: TComponentClass = TServerWebModule;
implementation
{%CLASSGROUP 'System.Classes.TPersistent'}
{$R *.dfm}
uses
Server.Ignition;
procedure TServerWebModule.ServerWebModuleDefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
inherited;
if not TServerEngine.Default.HandleRequest(Request, Response) then
begin
Response.ContentType := 'application/json';
Response.Content :=
'{"success": false, "details": '
+ '{'
+ '"error": "Request not found",'
+ '"pathinfo": "' + Request.PathInfo + '"'
+ '}'
+ '}';
end
else
Handled := True;
end;
end.