#1 2015-01-05 01:30:23

vladon
Member
From: Naberezhnye Chelny
Registered: 2014-09-03
Posts: 8
Website

[NOOBIE] How to get method parameter after slash?

For example, full url is http://myserver/MyMethod/Parameter

How can I get Parameter as a string from Ctxt: TSQLRestServerURIContext object?

Last edited by vladon (2015-01-05 01:30:57)

Offline

#2 2015-01-05 01:51:43

vladon
Member
From: Naberezhnye Chelny
Registered: 2014-09-03
Posts: 8
Website

Re: [NOOBIE] How to get method parameter after slash?

Will this be OK?

function TCustomRestServer.GetAfterSlashParam(Ctxt: TSQLRestServerURIContext): string;
var
  uri, urifull: string;
begin
  uri := UTF8ToString(Ctxt.URI);
  urifull := UTF8ToString(Ctxt.URIWithoutSignature);

  Result := urifull.Substring(urifull.IndexOf(uri) + uri.Length + 1);
end;

Offline

#3 2015-01-05 08:32:14

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: [NOOBIE] How to get method parameter after slash?

You may use directly Ctxt.URIBlobFieldName, I guess.
But text after any ? in the URI would be stored not in URIBlobFieldName but in Ctxt.Parameters.

Offline

#4 2015-01-05 12:10:45

vladon
Member
From: Naberezhnye Chelny
Registered: 2014-09-03
Posts: 8
Website

Re: [NOOBIE] How to get method parameter after slash?

ab wrote:

You may use directly Ctxt.URIBlobFieldName, I guess.

But it does not work, when Parameter starts with any number.

Offline

Board footer

Powered by FluxBB