$darkmode
cloe::Request Class Referenceabstract

#include <handler.hpp>

Inheritance diagram for cloe::Request:

Public Member Functions

virtual RequestMethod method () const =0
 
virtual ContentType type () const =0
 
virtual const std::string & body () const =0
 
virtual const std::string & uri () const =0
 
virtual const std::string & endpoint () const =0
 
virtual const std::map< std::string, std::string > & query_map () const =0
 
virtual bool has_json () const
 
virtual fable::Json as_json () const
 

Detailed Description

A Request represents an HTTP request sent by an external client.

This may contain data, for example when the request is a POST request.

  • The interface here is fully const, as it does not make sense to modify a request.

Member Function Documentation

◆ as_json()

virtual fable::Json cloe::Request::as_json ( ) const
inlinevirtual

Helper method that tries to convert the body to a JSON object.

Here is the call graph for this function:

◆ body()

virtual const std::string& cloe::Request::body ( ) const
pure virtual

Returns the body of the request as a reference to a string.

  • If the request does not contain a body, the return value is an empty string.

Implemented in oak::Request, and oak::RequestStub.

Here is the caller graph for this function:

◆ endpoint()

virtual const std::string& cloe::Request::endpoint ( ) const
pure virtual

Returns just the endpoint part of the URI.

For example:

https://localhost:8080/cloe/simulation?type=json => /cloe/simulation

Implemented in oak::Request, and oak::RequestStub.

◆ has_json()

virtual bool cloe::Request::has_json ( ) const
inlinevirtual

Helper method that returns whether the header specifies that there is JSON data.

Here is the call graph for this function:

◆ method()

virtual RequestMethod cloe::Request::method ( ) const
pure virtual

Returns what method was used on this request, for example GET or POST.

Implemented in oak::Request, and oak::RequestStub.

◆ query_map()

virtual const std::map<std::string, std::string>& cloe::Request::query_map ( ) const
pure virtual

Returns a key-value map of the query parameters.

Implemented in oak::Request, and oak::RequestStub.

◆ type()

virtual ContentType cloe::Request::type ( ) const
pure virtual

Returns the type, if any, of the content.

Note that the client may not send the right content type for the content. This function checks the Content-Type header, and if that is not set, it may optionally check the body itself.

  • If there is no content, NOT_APPLICABLE is returned.
  • If there is content, but we don't know what kind of data, then UNKNOWN is returned.

Implemented in oak::Request, and oak::RequestStub.

Here is the caller graph for this function:

◆ uri()

virtual const std::string& cloe::Request::uri ( ) const
pure virtual

Returns the path, including query string.

Implemented in oak::Request, and oak::RequestStub.


The documentation for this class was generated from the following file: