How to map custom HTTP method prefixes on a Delphi DataSnap REST server

RESTful services created using Delphi DataSnap provide default prefix mapping for public REST methods from a DataSnap server based on the type of HTTP method. These are the following:

HTTP Method type Prefix Example GET none MyValue POST Update UpdateMyValue PUT Accept AcceptMyValue DELETE Cancel CancelMyValue 

The documentation states: "The mapping template can be overridden. The user can override the mapping for each type based on the class name and method name parameters." However, I was completely unable to find documentation on how to do this. I want to change the prefix of my PUT from Accept to another. How to do it?

I should note that another posting here on StackOverflow ( REST Datasnap overrides the mapping of URIs ) is trying to answer this question by indicating that the TDSHTTPService has methods to perform this mapping. The same post also mentions the white Marco CantΓΉ DataSnap document, which is supposed to also describe how to do this. This white paper says, "You can configure these mappings by processing the four appropriate event handlers for the DSHTTPWebDispatcher component."

In RAD Studio XE, the TDSHTTPService and TDSHTTPWebDispather components had four specific events corresponding to the four HTTP methods listed above and which were designed to match the prefix. These methods do not exist in XE2 and later.

+6
source share
1 answer

While it was possible to map calls to the DataSnap method POST, PUT, and DELETE HTTP with alternative prefixes in XE, this cannot be done in Delphi XE2 through Delphi XE8. In these versions, you must adhere to "Update", "Accept" and "Cancel" respectively. And honestly, this is not a real problem.

It is worth noting that you can map various calls to HTTP methods using Embarcadero Enterprise Mobility Services (EMS). I wrote white paper and recorded a video presentation about EMS for Embarcadero. To access white paper and video, use the following URL.

http://www.embarcadero.com/rad-in-action/mobilizing-your-business-with-cary-jensen

0
source

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


All Articles