Written by

Question Thomas Noitz · Dec 1, 2017

REST-Service Call-Parameter Method in other class

Hi guys,

is there a way to get the Call-Parameter in an UrlMap to call a method that lies in another class?

Example:

I have a generic class 'RestApi' where I define all my routes for the different Rest-Services I offer - in order to get the same URL for every service.

<Route Url="/checkUID/:uid/:supplierid/" Method="GET" Call="checkUID"/>

This way the checkUID-Method has to be in the class 'RestApi' where my routes are defined. If I dont want to have all methods implemented in the same generic class, is it possible to get the Call-Parameter to call for example the method 'checkUID' in the class 'UID'?

Thanks,

Thomas

Comments

Dmitry Maslennikov · Dec 1, 2017

You can use colon to achieve it

<Route Url="/checkUID/:uid/:supplierid/" Method="GET" Call="Some.Other.Class:checkUID"/>

With Map tag in UrlMap, you can simply split your big UrlMap by multiple classes

0
Thomas Noitz  Dec 1, 2017 to Dmitry Maslennikov

Thanks Dimitry! That was exactly what I was searching for!

Thomas

0
Thomas Noitz  Dec 4, 2017 to Eduard Lebedyuk

Thank you Eduard - works great!

Just for additional clarification because I ran across this problem: the URL Map in the forwarded class (Api.v1 in your example) must not contain the Prefix of the URL (/v1 in your example). Its just the remainder of the REST URL that will be processed by the URL Map of the subclass.

Thomas

0
Eduard Lebedyuk · Dec 1, 2017

URL map can also be splitted into several parts:

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>

<!-- Api version 1 -->
<Map Prefix="/v1" Forward="Api.v1"/>

<!-- Api version 2 -->
<Map Prefix="/v2" Forward="Api.v2"/>

</Routes>
}

And brokers in Api.v1 and Api.v2 would process the requests according to their URL Map.

0