Hi Everybody,
I'm using TMS XData\Demos\Swagger demos as basic model, and I'm building a REST service on top of it.
I put some new memos in main form in order to show the lastest request.
I call procedure LogCall for each service implementation.
How can I put get the response body and headers of the latest call (for example put that latest response body in a memo in main form)?
Also is there any method that I can use in Data\Demos\Swagger demos I can Intercept and modify the reponse, like Response := StringReplace(Response,'$id','dummy',[replaceAll]);
[Route('activity-info')]
[HttpGet] function GetActivityInfo(activityId: TGUID ):T_ActivityInfo;
function TAVSessionService.GetActivityInfo(activityId: TGUID ):T_ActivityInfo;
begin
LogCall;
raise EXDataHttpException.Create(500, 'not implemented yet');
Result := T_ActivityInfo.Create;
//deff
end;
procedure LogCall;
begin
fmain.MainForm.mem_body_request.Clear;
fmain.MainForm.mem_last_header.Clear;
fmain.MainForm.mem_user.Clear;
fmain.MainForm.mem_auth.Clear;
if add_fake_token then AddFakeAuth;
DeserializeJWT;
fmain.MainForm.mem_last_header.Text := TXDataOperationContext.Current.Request.Headers.RawWideHeaders;
fmain.MainForm.mem_body_request.Text := TEncoding.UTF8.GetString(TXDataOperationContext.Current.Request.Content);
fmain.MainForm.mem_Info.Lines.Insert(0,FormatDateTime('yyyy.mm.dd hh:nn:ss >',now())+ '[' + TXDataOperationContext.Current.Request.RemoteIp + '] ' + TXDataOperationContext.Current.Request.Method + ' ' + TXDataOperationContext.Current.Request.RawUri);
end;
Thanks,
Mihai