#include <response.hpp>

Public Member Functions

 response ()=default
 
http::status_t status () const
 
http::version version () const
 
const http::contentcontent () const
 
const t_string_param_map & headers () const
 
const std::string & body () const
 
std::string to_string () const
 
std::list< matador::buffer_viewto_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
 

Detailed Description

The response class bundles all information of the result of an HTTP request.

Constructor & Destructor Documentation

◆ response()

matador::http::response::response ( )
default

Default constructor

Member Function Documentation

◆ bad_request()

static response matador::http::response::bad_request ( )
static

Creates a BAD_REQUEST response

Returns
The created BAD_REQUEST response

◆ body()

const std::string & matador::http::response::body ( ) const

Returns the raw body as string.

Returns
The body of the response

◆ content()

const http::content & matador::http::response::content ( ) const

returns the content information of the response consisting of

  • length
  • type
  • md5
  • language
Returns
The response content information

◆ from_file()

static response matador::http::response::from_file ( const std::string &  file_path)
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.

Parameters
file_pathPath of the file
Returns
The created OK response

◆ headers()

const t_string_param_map & matador::http::response::headers ( ) const

Return the response HTTP header.

Returns
The HTTP header

◆ no_content()

static response matador::http::response::no_content ( )
static

Creates a NO_CONTENT response

Returns
The created NO_CONTENT response

◆ not_found() [1/2]

static response matador::http::response::not_found ( )
static

Creates a NOT_FOUND response

Returns
The created NOT_FOUND response

◆ not_found() [2/2]

template<class T >
response matador::http::response::not_found ( const T &  obj)
static

Creates a NOT_FOUND response with the given object converted to string as body

Template Parameters
TType of the object
Parameters
objObject to be converted
Returns
The created NOT_FOUND response

◆ ok() [1/5]

static response matador::http::response::ok ( const matador::json body)
static

Creates an OK response of the given json object as body.

Parameters
bodyThe body data as json object
Returns
The created OK response

◆ ok() [2/5]

template<class T >
response matador::http::response::ok ( const object_ptr< T > &  obj)
static

Creates an OK response with the give object_ptr converted into a json string as body

Template Parameters
TType of the object
Parameters
objObject to convert
Returns
The created OK response

◆ ok() [3/5]

template<class T >
response matador::http::response::ok ( const object_view< T > &  view)
static

Creates an OK response with the give object_view of objects of type T converted into a json string as body

Template Parameters
TType of the object in the view
Parameters
viewThe object view to convert
Returns
The created OK response

◆ ok() [4/5]

static response matador::http::response::ok ( const std::string &  body,
mime_types::types  type 
)
static

Creates an OK response with the given body string and the given media type

Parameters
bodyBody as string
typeMedia type of body
Returns
The created OK response

◆ ok() [5/5]

template<class T >
response matador::http::response::ok ( const T &  obj)
static

Creates an OK response with the given object converted to a json string as body

Template Parameters
TType of the object
Parameters
objObject to be converted as json body
Returns
The created OK response

◆ redirect()

static response matador::http::response::redirect ( const std::string &  location)
static

Creates a REDIRECT response to the given location.

Parameters
locationLocation to redirect to
Returns
The created REDIRECT response

◆ status()

http::status_t matador::http::response::status ( ) const

Returns the HTTP status of the reponse

Returns
The status of the response

◆ to_buffers()

std::list< matador::buffer_view > matador::http::response::to_buffers ( ) const

Creates a list of view buffer containing the response ready to be send.

Returns
List of buffer views containing the response ready to send

◆ to_string()

std::string matador::http::response::to_string ( ) const

Returns the response as a string

Returns
Response as string

◆ version()

http::version matador::http::response::version ( ) const

Returns the HTTP version of the response

Returns
The HTTP version of the response

The documentation for this class was generated from the following file:
  • matador/http/response.hpp