REST Datasnap overrides URI mapping

I wrote a small REST server with datasnap REST data in delphi XE2. There is a default mapping between HTTP methods (POST, PUT, etc.) and the functions defined in delphi, this is done using the delphi component.

This wiki entry describes the mapping of a URI, but also notes that the default mapping can be canceled by the programmer.

The display template can be overridden. The user can override the mapping for each type based on the class name and parameters of the method name.

But I did not find an explanation of how to override the mapping.

How to change the default display?

+3
source share
2 answers

The TDSHTTPService component has events in which you can specify a mapping for each type. These events are called RESTMethodNameMapDELETE, RESTMethodNameMapGET, RESTMethodNameMapPOST and RESTMethodNameMapPUT.

This is also explained in REST white paper by Marco Cantu, which explains a lot about REST and Datasnap.

+2
source

I was interested in the same thing, and I did some experiments. Apparently, at least partially, you can control the URL. In particular, I tried to change the part of the class name in the url.

Essentially, if you use TComponent decomposition, you can call the class anything. This will not work if you abandon the TDataModule. In this case, you can create a class and an alias that you can call whatever you want, which deviates from your TDataModule.

You need to do some cleaning up in client binding when trying to bind to this, but it seems to work, at least for simple tests.

Read more on the Embarcadero forums.

https://forums.embarcadero.com/thread.jspa?threadID=77624&tstart=0

+1
source

Source: https://habr.com/ru/post/981730/


All Articles