-
Notifications
You must be signed in to change notification settings - Fork 22
The magic of rest_request_binding
Wolfgang Sourdeau edited this page Nov 29, 2013
·
1 revision
/** addRouteSyncReturn variants (2):
*
* Then "pmf" handler function receives parameters from rest values, as
* configured. Its return value is then passed to the "transformResult"
* function as parameter, which is expected to return a valid json
* representation of that result, this pair of function has no impact on the
* http status code (always set to 200, unless an exception is thrown) nor on
* the content-type (always set to "application/json"). */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename TransformResult,
typename... Params>
void
addRouteSyncReturn(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
const TransformResult & transformResult,
Return (Obj::* pmf) (Args...),
Ptr ptr,
Params&&... params);
/* Same as above, with pmf const. */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename TransformResult,
typename... Params>
void
addRouteSyncReturn(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
const TransformResult & transformResult,
Return (Obj::* pmf) (Args...) const,
Ptr ptr,
Params&&... params);
/** addRouteReturnStatus variants (2)
*
* The "pmf" handler function receives parameters from rest values, as
* configured, and returns a pair where the first member is an integer
* representing the http status code and the second member the body of the
* response. The returned content-type is always "application/json". */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteReturnStatus(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
std::pair<int, Return> (Obj::* pmf) (Args...),
Ptr ptr,
Params&&... params);
/* same as above, with pmf const */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteReturnStatus(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
std::pair<int, Return> (Obj::* pmf) (Args...) const,
Ptr ptr,
Params&&... params);
/** addRouteSync variants (2)
*
* Then "pmf" handler function receives parameters from rest values, as
* configured and its return value, if present, is ignored. The function
* execution has no impact on the http status code (always set to 200, unless
* an exception is thrown), on the body (always empty) nor on the content-type
* (always set to "application/json"). */
*/
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteSync(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
Return (Obj::* pmf) (Args...),
Ptr ptr,
Params&&... params);
/* same as above, with pmf const */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteSync(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
Return (Obj::* pmf) (Args...) const,
Ptr ptr,
Params&&... params);
/** addRouteAsync variants (2)
*
* Then "pmf" handler function receives parameters from rest values, as
* configured and receives the connection and context as parameter but does
* not return anything. This function has thus full control over the contents
* being returned, including the status code, the content-type and the body
* and is responsible for invoking sendResponse once and only once.
*/
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteAsync(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
Return (Obj::* pmf) (Args...),
Ptr ptr,
Params&&... params);
/* same as above, with pmf const */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteAsync(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
Return (Obj::* pmf) (Args...) const,
Ptr ptr,
Params&&... params)
/* addRouteAsyncThen variants (1)
*
* Then "exc" handler function receives parameters from rest values, as
* configured, and receives the connection and context as parameters. Its
* return value is then passed as parameter to the "then" function, which will
* also receive the connection and context as parameters. The difference
* between the "exc" and "then" is that the "exc" is the only one between the
* two to receive the rest parameters. This is very similar to
* "addRouteSyncReturn", except in this case that either of the functions is
* responsible for invoking "sendResponse" on the ConnectionId instance.
*/
template<typename Return, typename... Args,
typename... Params, typename ThenFn>
void
addRouteAsyncThen(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
const ThenFn & then,
const ExcFn & exc,
const std::function<Return (Args...)> & fn,
Params&&... params);
/** addRouteSyncJsonReturn variants (3)
*
* Then "fn" handler function receives parameters from rest values, as
* configured, and receives the connection and context as parameters. Its
* return value is then converted to Json automatically, provided a
* DefaultDescription instance exists for its return type. "fn" must not
* invoke sendResponse.
*/
template<typename Return, typename... Args, typename... Params>
void
addRouteSyncJsonReturn(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
const std::function<Return (Args...)> & fn,
Params&&... params);
/* Same as above, with "pmf" and "ptr" passed as a bound function to
* addRouteSyncJsonReturn. */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteSyncJsonReturn(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
Return (Obj::* pmf) (Args...),
Ptr ptr,
Params&&... params);
/* Same as above, with pmf const. */
template<typename Return, typename Obj, typename... Args, typename Ptr,
typename... Params>
void
addRouteSyncJsonReturn(RestRequestRouter & router,
PathSpec path, RequestFilter filter,
const std::string & description,
const std::string & resultDescription,
Return (Obj::* pmf) (Args...) const,
Ptr ptr,
Params&&... params)