boost::http::route_result

The result type returned by route handlers.

Synopsis

class route_result;

Description

This class represents the outcome of a route handler. Handlers return this type to indicate how the router should proceed. Construct from a directive constant or an error code:

route_task my_handler(route_params& p)
{
    if(! authorized(p))
        co_return route_next;        // try next handler

    if(auto ec = process(p); ec)
        co_return ec;                // return error

    co_return route_done;            // success
}

Checking Results

Use what() to determine the directive, and error() to retrieve any error code:

route_result rv = co_await handler(p);
if(rv.what() == route_what::error)
    handle_error(rv.error());

Member Functions

Name

Description

route_result [constructor]

Construct from a directive constant.

error

Return the error code, if any.

failed

Return true if the result indicates an error.

what

Return the directive for this result.

Friends

Name Description

boost::http::route_error

Construct from an error enum.

boost::http::route_error

Construct from an error code.

See Also

route_task, route_what, route_done, route_next

Created with MrDocs