#1 2013-08-13 09:27:37

ncook
Member
From: Australia
Registered: 2013-08-13
Posts: 19

Remainder of the REST URI

I'm building a REST service based application using mORMot.

For most of the application I am using interfaced based methods very successfully with a Delphi client, JSON encoded arguments and results, using the techniques as described in chapter 17 of the SAD 1.18 documentation.
(By the way, congratulations on having such good documentation. It really is a breath of fresh air.)

For another part of the application I am returning dynamically built HTML pages to a web browser. I have set up a test service using the techniques as described in chapter 15, and I now have HTML pages being built and returned. I was very pleased how simple that was to set up.

However the technique requires any arguments to the method to be passed as parameters with a URI syntax like "/root/Sum?a=3.12&b=4.2" (to use an example from the SAD).
I would like to be able to pass additional information to my method as part of the URI using a syntax more like "/root/exampleMethod/moreDetails/aboutWhat/iAmTrying/toDo". I have seen this technique used in several other frameworks (especially ASP.Net MVC) and it has great appeal.

Taking this example, I would have no trouble calling the method "exampleMethod". I would be quite happy within that method, to decode the remainder of the URI myself (the "/moreDetails/aboutWhat/iAmTrying/toDo" part). I am not expecting the framework to do anything with that information automatically.
But I have not yet been able to find any way to get access to anything that will tell me what the remainder of the URI was.  For example: TSQLRestServerCallBackParams.URI only returns "exampleMethod".

Is there some way to get access the the remainder of the URI from within my method (hopefully from something in TSQLRestServerCallBackParams)?

If there currently is not, could this information be made available? (For example: as TSQLRestServerCallBackParams.FullURI, or TSQLRestServerCallBackParams.ExtendedURI, or TSQLRestServerCallBackParams.URIAfterMethod, or something like that.)

Last edited by ncook (2013-08-13 09:29:41)

Offline

#2 2013-08-13 09:37:44

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

Re: Remainder of the REST URI

Interface based methods expect indeed a fixed layout.

I suspect that method-based services are what you need.

For instance, any call to the URI "/root/MyMethodService/ABC/DEF/GHI/123" will execute the server method MyMethodService, and pass the URI as parameter.
If TSQLRestServerCallBackParams.URI does not contain the whole content, you can access the raw HTTP parameters from TSQLRestServerCallBackParams.Call^, including the raw URI.
So you would be able to process all parameters in this method code.

Offline

#3 2013-08-13 09:43:55

ncook
Member
From: Australia
Registered: 2013-08-13
Posts: 19

Re: Remainder of the REST URI

Thank you. Especially for the quick response.

That was exactly what I needed.

Offline

Board footer

Powered by FluxBB