Advertisement
danieleteti

DMVCFramework :: MVCRESTClient, Async

Oct 6th, 2022
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.91 KB | Source Code | 0 0
  1. procedure TForm9.btnGETClick(Sender: TObject);
  2. begin
  3.   var lClient: IMVCRESTClient := TMVCRESTClient.Create;
  4.   lClient.Async(
  5.     procedure(Resp: IMVCRESTResponse)
  6.     begin
  7.       Memo1.Lines.Text := Resp.Content;
  8.     end,
  9.     procedure(E: Exception)
  10.     begin
  11.       Memo1.Lines.Clear;
  12.       Memo1.Lines.Add('ERROR');
  13.       Memo1.Lines.Add(E.ClassName + ': ' + E.Message)
  14.     end,
  15.     True).Get('https://httpbin.org/get');
  16. end;
  17.  
  18. procedure TForm9.btnPOSTClick(Sender: TObject);
  19. begin
  20.   var lClient: IMVCRESTClient := TMVCRESTClient.Create;
  21.   lClient.Async(
  22.     procedure(Resp: IMVCRESTResponse)
  23.     begin
  24.       Memo1.Lines.Text := Resp.Content;
  25.     end,
  26.     procedure(E: Exception)
  27.     begin
  28.       Memo1.Lines.Clear;
  29.       Memo1.Lines.Add('ERROR');
  30.       Memo1.Lines.Add(E.ClassName + ': ' + E.Message)
  31.     end, True)
  32.     .Post('https://httpbin.org/post', 'HELLO WORLD', TMVCMediaType.TEXT_PLAIN);
  33. end;
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement