HTTPApi in Delphi

Hi,

On the HTTPApi, in the sample here:
https://docs.remotingsdk.com/Servers/Concepts/HttpAPI/SampleDelphi/

I see the calculate method being added manually. How can I just add all methods from my RODL to the HTTPApi?

I see in the .NET dcumentation i can add an attribute there to enable HTTPI path but there is no metnion in the Delphi docs.

And how does the JSONMessage tie into this?

Thanks,

For classic RODL-based servers the HttpAPI based attributes have to be set via RODL.

The following custom attributes can be applied to RODL methods:

  • HttpApiPath
  • HttpApiMethod
  • HttpApiResult
  • HttpApiTags
  • HttpApiOperationId

These custom RODL attributes have exactly the same meaning as the corresponding attribute properties in a CodeFirst server.

However due to the text-only nature of custom RODL attribute values the HttpApiResult and HttpApiTags attributes are set in a slightly different way:

  • HttpApiResult value should be a numeric Http response code. F.e. the value of this attribute can be set to “200” or “201” but it cannot be set to “OK” or “Created” .
  • HttpApiTags should be set to a comma-separated list of tags, f.e. "sometag,someothertag"

Also service method parameter can be marked with RODL attributes HttpApiQueryParameter or HttpApiHeaderParameter . If the value of this attribute is set to 1 then it is expected that the marked parameter will be passed via Url query string or Http headers accordingly

Hi,

for RODL-based services, you can use Http Api Attributes editor inside Service Builder:


Adding of HttpApiQueryParameter/ HttpApiHeaderParameter also possible:

for CodeFirst-based services, you should use ROCustom attribute, like:

    [ROServiceMethod]
    [ROCustom('httpapipath', 'path')]
    [ROCustom('httpapimethod', 'GET')]
    [ROCustom('httpapiresult', '200')]
    [ROCustom('httpapitags', 'tag')]
    [ROCustom('httpapioperationid', 'method')]
    procedure NewMethod(
                  [ROCustom('httpapiheaderparameter', '1')] 
                  const NewParam: Integer); virtual;