I need to write a simple REST-server in Delphi and a client in Ruby on Rails. I've watched all of the videos by Marco Cantu about REST in Delphi and I've got a question:
How can Delphi process requests like "/users/1"
where 1
is the ID of a user?
All of the examples I've seen use simple functions (like EchoString(value)
or ReverseString(Value)
) and the request is "Datasnap/rest/ClassName/EchoString/Value"
, but I need a request like "Datasnap/rest/classname/123"
.
For example: TContractsCollection
is a collection of contracts and I want to view the contract with ID=324556
. So in a browser (and in the RoR client) it will be (for example):
"http://localhost:3000/DataSnap/rest/TContractsCollection/324556"
But Delphi writes:
"TContractsCollection method not found in the server method list"
Any ideas?
You can define a function in the TdmServerModule like function
ProcessContract(ContractNo:Integer): String
when
http://localhost:3000/DataSnap/rest/ProcessContract/324556
is called, the ContractNo will be set to 324556
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.