Class AbstractApiServer

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class AbstractApiServer : public axr::sdk::net::IApiServer

Abstract implementation of the IApiServer interface implementing common functionality such as routing.

Subclassed by axr::sdk::net::WsppApiServer

Public Functions

inline virtual ~AbstractApiServer()
virtual void Use(RequestHandler Handler)

Registers a handler function that will be used in all HTTP request processing.

virtual void Use(const utility::string_t &Method, const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers a handler function that will be used in HTTP request processing for the given method type and path.

virtual void Delete(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP DELETE requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP DELETE requests for the given endpoint path.

virtual void Get(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP GET requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP GET requests for the given endpoint path.

virtual void Head(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP HEAD requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP HEAD requests for the given endpoint path.

virtual void Post(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP POST requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP POST requests for the given endpoint path.

virtual void Put(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP PUT requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP PUT requests for the given endpoint path.

virtual void Upgrade(const utility::string_t &Path, std::initializer_list<RequestHandler> Handlers)

Registers the list of request handler functions to handle HTTP Upgrade (WebSocket) requests matching the specified path.

Parameters
  • Path – The endpoint path that the handler(s) will process.

  • Handlers – The list of request handler functions that will process HTTP Upgrade (WebSocket) requests for the given endpoint path.

Protected Functions

AbstractApiServer(std::shared_ptr<Configuration> Config)
void HandleRequest(IHttpRequest Request)

Processes an incoming HTTP request forwarding it to all matching endpoint handlers. Implementing servers should call this function whenever a new HTTP request is received.

Protected Attributes

std::shared_ptr<Configuration> m_Config

The SDK configuration object to reference.

std::map<utility::string_t, std::vector<RequestHandler>> m_EndpointHandlers

A map of endpoint paths to the list of request handlers that will process requests.