#include <response.hpp>
Public Member Functions | |
response ()=default | |
http::status_t | status () const |
http::version | version () const |
const http::content & | content () const |
const t_string_param_map & | headers () const |
const std::string & | body () const |
std::string | to_string () const |
std::list< matador::buffer_view > | to_buffers () const |
Static Public Member Functions | |
template<class T > | |
static response | ok (const T &obj) |
template<class T > | |
static response | ok (const object_ptr< T > &obj) |
template<class T > | |
static response | ok (const object_view< T > &view) |
static response | ok (const matador::json &body) |
static response | ok (const std::string &body, mime_types::types type) |
static response | no_content () |
static response | not_found () |
template<class T > | |
static response | not_found (const T &obj) |
static response | bad_request () |
static response | redirect (const std::string &location) |
static response | from_file (const std::string &file_path) |
Friends | |
class | response_parser |
The response class bundles all information of the result of an HTTP request.
|
default |
Default constructor
|
static |
Creates a BAD_REQUEST response
const std::string & matador::http::response::body | ( | ) | const |
Returns the raw body as string.
const http::content & matador::http::response::content | ( | ) | const |
returns the content information of the response consisting of
|
static |
Creates an OK response from a file at the given path. The media type is determined by the file extension. If unknown media type is PLAN_TEXT.
file_path | Path of the file |
const t_string_param_map & matador::http::response::headers | ( | ) | const |
Return the response HTTP header.
|
static |
Creates a NO_CONTENT response
|
static |
Creates a NOT_FOUND response
|
static |
Creates a NOT_FOUND response with the given object converted to string as body
T | Type of the object |
obj | Object to be converted |
|
static |
Creates an OK response of the given json object as body.
body | The body data as json object |
|
static |
Creates an OK response with the give object_ptr converted into a json string as body
T | Type of the object |
obj | Object to convert |
|
static |
Creates an OK response with the give object_view of objects of type T converted into a json string as body
T | Type of the object in the view |
view | The object view to convert |
|
static |
Creates an OK response with the given body string and the given media type
body | Body as string |
type | Media type of body |
|
static |
Creates an OK response with the given object converted to a json string as body
T | Type of the object |
obj | Object to be converted as json body |
|
static |
Creates a REDIRECT response to the given location.
location | Location to redirect to |
http::status_t matador::http::response::status | ( | ) | const |
Returns the HTTP status of the reponse
std::list< matador::buffer_view > matador::http::response::to_buffers | ( | ) | const |
Creates a list of view buffer containing the response ready to be send.
std::string matador::http::response::to_string | ( | ) | const |
Returns the response as a string
http::version matador::http::response::version | ( | ) | const |
Returns the HTTP version of the response