Question
· Feb 20, 2019

Extend XData UrlMap

Hi all,

I'm wondering if is possible to extend the UrlMap.

I want to create a base class and one method will be in all extended classes, so I've tried to create the map route in parent class, and the specific methods in extended class. But it doesn't work.

I've create the method in parent class and I've wrote the map in extended class. It works, but I want to put it in base class to prevent forget this call.

Note: The base class extend to %CSP.RES

Best regards,

Francisco Lopez

Discussion (5)1
Log in or sign up to continue

You can extend UrlMap only by splitting routes

While in one class you have this

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/class/:namespace/:classname" Method="GET" Call="GetClass" Cors="true"/>
<Map Prefix="/something" Forward="Some.Your.Class"/>
</Routes>
}

You can add one more class, whic will work only with routes started with /something with

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/more" Method="GET" Call="More" Cors="true"/>
</Routes>
}

Where real route will be /something/more

I've tried to forward to "class1" when Prefix is nothing (or "/") and other prefix ("/client2") to "class2"

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>        
    <Map Prefix="/" Forward="My.Code.BS.Class1" />
    <Map Prefix="/Client2" Forward="My.Code.BS.Class2" />
</Routes>
}

In Security - Applications - Web Applications, I've defined the following entry

Then I've called using the following links

  1. http://localhost:57772/api/myprocess/method1 (I'm calling to a method in Class1)
  2. http://localhost:57772/api/myprocess/Client2/method1 (I'm calling to a method in Class2)

The first link doesn't work (404 Not found), the second one works fine.

Is not possible to add a prefix for link 1 because this is the current link for class1 in production environment, the new deploy is for class2

Any idea?

Thanks Eduard,

Note: I've udpdated my comment, to show that there is two customers

Currently we are not able to rename the link of the Client1 to http://localhost:57772/api/myprocess/Client1/method1, the new customer will have this prefix without problem (http://localhost:57772/api/myprocess/Client2/method1)

Now we have solved this problem adding the forward in Class1, and not using the My.Code.BS.ApiRoute.

Of course, In Security - Applications - Web Applications, I've defined the Dispatch class to My.Code.BS.Class1

Next iteration we'll try to change the URL of Client1 and use the ApiRoute class.

Best regards