-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnleash.Rest.pas
58 lines (45 loc) · 1.11 KB
/
Unleash.Rest.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
unit Unleash.Rest;
interface
uses
REST.Client,
REST.Types,
System.SysUtils,
IPPeerClient;
type
TRestConnection = class
protected
FRestResponse: TRESTResponse;
FRestRequest: TRESTRequest;
FRestClient: TRESTClient;
public
constructor Create(const BaseUrl: string);
destructor Destroy; override;
property Request: TRESTRequest
read FRestRequest;
property Client: TRESTClient
read FRestClient;
property Response: TRESTResponse
read FRestResponse;
end;
implementation
constructor TRestConnection.Create(const BaseUrl: string);
begin
inherited Create;
FRestResponse := TRESTResponse.Create(nil);
FRestRequest := TRESTRequest.Create(nil);
FRestClient := TRESTClient.Create(nil);
FRestClient.BaseURL := BaseUrl;
FRestClient.HandleRedirects := True;
FRestRequest.Client := FRestClient;
FRestRequest.Response := FRestResponse;
FRestRequest.SynchronizedEvents := False;
FRestRequest.Accept := 'application/json';
end;
destructor TRestConnection.Destroy;
begin
FRestClient.Free;
FRestRequest.Free;
FRestResponse.Free;
inherited;
end;
end.