jsonMethodHandler

private fnHTTPServerRequestDelegate jsonMethodHandler(alias Func, size_t ridx, T)(T inst, ref RestInterface!T intf)

Generate an handler that will wrap the server's method

This function returns an handler, generated at compile time, that will deserialize the parameters, pass them to the function implemented by the user, and return what it needs to return, be it header parameters or body, which is at the moment either a pure string or a Json object.

One thing that makes this method more complex that it needs be is the inability for D to attach UDA to parameters. This means we have to roll our own implementation, which tries to be as easy to use as possible. We'll require the user to give the name of the parameter as a string to our UDA. Hopefully, we're also able to detect at compile time if the user made a typo of any kind (see genInterfaceValidationError).

Note

Lots of abbreviations are used to ease the code, such as

PTT (ParameterTypeTuple), WPAT (WebParamAttributeTuple) and PWPAT (ParameterWebParamAttributeTuple).

Parameters

Ttype of the object which represent the REST server (user implemented).
FuncAn alias to the function of T to wrap.
instREST server on which to call our Func.
settingsREST server configuration.

Returns

A delegate suitable to use as an handler for an HTTP request.