ark::rest::RestService

Defined in header “ark/rest/rest_service.hh”.


This is a generic rest service. It instantiates an HTTP server, and you can add handlers to it (either serializable strong types, or just consuming generic HTTP responses).

It is generally a pass-through for the HTTP server, but it does provide some additional support around metrics & serialization.

Methods

  • RestService(RestServiceConfiguration config, const std::string & metrics_endpoint)
    Constructor. Initializes the service.

  • void poll(std::chrono::nanoseconds duration)
    Polls the REST service, waiting for incoming messages to handle.

  • comms::NetworkAddress address()
    Returns the address that this server is running at.

  • void add_callback(const std::string & path, const comms::StaticMemoryCallback & callback)
    Adds a standard callback to the HTTP service. Use this if you need access to the raw HTTP request structure.

  • void add_callback(const std::string & path, std::function< comms::HttpResponse(const Authorization &authorization, const comms::HttpRequest &request)> callback)
    Adds a standard callback to the HTTP service. Use this if you need access to the raw HTTP request structure.

  • void add_callback(const std::string & path, std::function< comms::HttpResponse(const BearerToken &bearer_token, const comms::HttpRequest &request)> callback)
    Adds a standard callback to the HTTP service. Use this if you need access to the raw HTTP request structure.

  • void add_regex_callback(const std::string & path, const comms::StaticMemoryCallback & callback)
    Adds a regex callback to the HTTP service. Use this if you need access to the raw HTTP request structure.

  • void add_regex_callback(const std::string & path, std::function< comms::HttpResponse(const Authorization &authorization, const comms::HttpRequest &request)> callback)
    Adds a regex callback to the HTTP service. Use this if you need access to the raw HTTP request structure.

  • void add_callback(const std::string & path, std::function< comms::HttpResponse(const Type &type)> callback)
    Adds a new callback with the given strong (serializable) type. This will automatically deserialize incoming requests and handle basic metrics for you.

  • void add_callback(const std::string & path, std::function< comms::HttpResponse(const Authorization &authorization, const Type &type)> callback)
    Adds a new callback with the given strong (serializable) type. This will automatically deserialize incoming requests and handle basic metrics for you.

  • void add_callback(const std::string & path, std::function< comms::HttpResponse(const BearerToken &bearer_token, const Type &type)> callback)
    Adds a new callback with the given strong (serializable) type. This will automatically deserialize incoming requests and handle basic metrics for you.