2014-04-02 09:03:13 +02:00
|
|
|
unit MainFormU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2018-05-16 19:46:29 +02:00
|
|
|
Winapi.Windows,
|
|
|
|
Winapi.Messages,
|
|
|
|
System.SysUtils,
|
|
|
|
System.Variants,
|
|
|
|
System.Classes,
|
|
|
|
Vcl.Graphics,
|
|
|
|
Vcl.Controls,
|
|
|
|
Vcl.Forms,
|
|
|
|
Vcl.Dialogs,
|
|
|
|
IPPeerClient,
|
|
|
|
Vcl.StdCtrls,
|
2020-09-24 21:30:45 +02:00
|
|
|
MVCFramework.RESTClient.Intf,
|
2018-05-16 19:46:29 +02:00
|
|
|
MVCFramework.RESTClient,
|
|
|
|
REST.Client,
|
2014-04-02 09:03:13 +02:00
|
|
|
Data.Bind.Components,
|
2018-05-16 19:46:29 +02:00
|
|
|
Data.Bind.ObjectScope,
|
2020-09-24 21:30:45 +02:00
|
|
|
REST.Types;
|
2014-04-02 09:03:13 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TForm9 = class(TForm)
|
|
|
|
RESTClient1: TRESTClient;
|
|
|
|
RESTRequest1: TRESTRequest;
|
|
|
|
Button1: TButton;
|
|
|
|
Memo1: TMemo;
|
|
|
|
Button2: TButton;
|
|
|
|
procedure Button1Click(Sender: TObject);
|
|
|
|
procedure Button2Click(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
private
|
2020-09-24 21:30:45 +02:00
|
|
|
Clt: IMVCRESTClient;
|
2014-04-02 09:03:13 +02:00
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form9: TForm9;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
procedure TForm9.Button1Click(Sender: TObject);
|
|
|
|
begin
|
|
|
|
RESTRequest1.ExecuteAsync(
|
|
|
|
procedure
|
|
|
|
begin
|
|
|
|
Memo1.Lines.Text := RESTRequest1.Response.JSONValue.ToString;
|
|
|
|
end);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm9.Button2Click(Sender: TObject);
|
|
|
|
begin
|
2020-09-24 21:30:45 +02:00
|
|
|
Clt
|
|
|
|
.SetValidateServerCertificateProc(
|
|
|
|
procedure(const Sender: TObject; const ARequest: TURLRequest;
|
|
|
|
const Certificate: TCertificate; var Accepted: Boolean)
|
2014-04-02 09:03:13 +02:00
|
|
|
begin
|
2020-09-24 21:30:45 +02:00
|
|
|
//
|
|
|
|
Accepted := True;
|
|
|
|
end
|
|
|
|
)
|
|
|
|
.Async(
|
|
|
|
procedure(Resp: IMVCRESTResponse)
|
|
|
|
begin
|
|
|
|
Memo1.Lines.Text := Resp.Content;
|
|
|
|
Memo1.Lines.Add('Request Terminated successfully')
|
2018-05-16 19:46:29 +02:00
|
|
|
end,
|
|
|
|
procedure(E: Exception)
|
|
|
|
begin
|
|
|
|
ShowMessage(E.Message);
|
2020-09-24 21:30:45 +02:00
|
|
|
Memo1.Lines.Add('Request Terminated with errors')
|
|
|
|
end, True).Get('/people');
|
2014-04-02 09:03:13 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm9.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2020-09-24 21:30:45 +02:00
|
|
|
Clt := TMVCRESTClient.New.BaseURL('https://localhost');
|
2014-04-02 09:03:13 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|