-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRESTDataModule_frm.pas
87 lines (73 loc) · 1.85 KB
/
RESTDataModule_frm.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
unit RESTDataModule_frm;
interface
uses
System.SysUtils
,System.Classes
,IPPeerClient
,REST.Client
,Data.Bind.Components
,Data.Bind.ObjectScope
,REST.Types
,System.JSON
,HTTPApp;
type
TCategoryShow = class(TThread)
private
group_id : String;
protected
procedure Execute; override;
procedure DoOnTerminate(Sender: TObject);
public
constructor Create(group_id_in: String);
end;
type
TRESTDataModule = class(TDataModule)
RESTClient: TRESTClient;
Request: TRESTRequest;
Response: TRESTResponse;
private
{ Private declarations }
public
{ Public declarations }
end;
var
RESTDataModule: TRESTDataModule;
implementation
{%CLASSGROUP 'FMX.Controls.TControl'}
uses
HeaderFooterTemplate
,Categories_frm;
{$R *.dfm}
//####################################################################################
// The part that supports multithreading
//####################################################################################
constructor TCategoryShow.Create(group_id_in: String);
begin
inherited Create(True);
FreeOnTerminate := True;
OnTerminate := DoOnTerminate;
group_id := group_id_in;
Resume;
end;
procedure TCategoryShow.Execute;
var
RESTParam: string;
begin
RESTParam:='http://localhost:8443/show_categories?group_id='+group_id;
RESTDataModule.Request.Resource:= RESTParam;
RESTDataModule.Request.Method := rmGET;
try
try
RESTDataModule.Request.Execute;
finally
end;
except
end;
end;
procedure TCategoryShow.DoOnTerminate(Sender: TObject);
begin
Categories.Result_of_Category_List_Request(RESTDataModule.Response.StatusCode, RESTDataModule.Response.Content);
inherited;
end;
//####################################################################################
end.