Loading...
Searching...
No Matches
restinio::generic_request_t< Extra_Data > Class Template Reference

HTTP Request data. More...

`#include <request_handler.hpp>`

Inheritance diagram for restinio::generic_request_t< Extra_Data >:

## Public Member Functions

template<typename Extra_Data_Factory >
| generic_request_t (request_id_t request_id, http_request_header_t header, std::string body, impl::connection_handle_t connection, endpoint_t remote_endpoint, Extra_Data_Factory &extra_data_factory)
| Old-format initializing constructor.
template<typename Extra_Data_Factory >
| generic_request_t (request_id_t request_id, http_request_header_t header, std::string body, chunked_input_info_unique_ptr_t chunked_input_info, impl::connection_handle_t connection, endpoint_t remote_endpoint, Extra_Data_Factory &extra_data_factory)
| New-format initializing constructor.
const http_request_header_t & | header () const noexcept
| Get request header.
const std::string & | body () const noexcept
| Get request body.
template<typename Output = restinio_controlled_output_t>
auto | create_response (http_status_line_t status_line=status_ok())
auto | request_id () const noexcept
| Get request id.
connection_id_t | connection_id () const noexcept
| Get connection id.
const endpoint_t & | remote_endpoint () const noexcept
| Get the remote endpoint of the underlying connection.
nullable_pointer_t< const chunked_input_info_t > | chunked_input_info () const noexcept
| Get optional info about chunked input.
RESTINIO_NODISCARD Extra_Data & | extra_data () noexcept
| Get writeable access to extra-data object incorporated into a request object.
RESTINIO_NODISCARD const Extra_Data & | extra_data () const noexcept
| Get readonly access to extra-data object incorporated into a request object.

## Private Member Functions

void | check_connection ()

## Private Attributes

const request_id_t | m_request_id
const http_request_header_t | m_header
const std::string | m_body
const chunked_input_info_unique_ptr_t | m_chunked_input_info
| Optional description for chunked-encoding.
impl::connection_handle_t | m_connection
const connection_id_t | m_connection_id
const endpoint_t | m_remote_endpoint
| Remote endpoint for underlying connection.
impl::generic_request_extra_data_holder_t< Extra_Data > | m_extra_data_holder
| An instance of extra-data that is incorporated into a request object.

## Friends

template<typename UD >
impl::connection_handle_t & | impl::access_req_connection (generic_request_t< UD > &) noexcept

## Detailed Description

template<typename Extra_Data>
class restinio::generic_request_t< Extra_Data >

HTTP Request data.

Provides acces to header and body, and creates response builder for a given request.

Template Parameters

  Extra_Data | The type of extra-data to be incorporated into a request object.

Definition at line 207 of file request_handler.hpp.

## Constructor & Destructor Documentation

## generic_request_t() [1/2]

template<typename Extra_Data >
template<typename Extra_Data_Factory >

restinio::generic_request_t< Extra_Data >::generic_request_t | ( | request_id_t | request_id,
|  | http_request_header_t | header,
|  | std::string | body,
|  | impl::connection_handle_t | connection,
|  | endpoint_t | remote_endpoint,
|  | Extra_Data_Factory & | extra_data_factory
| ) |  |

inline

Old-format initializing constructor.

Can be used in cases where chunked_input_info_t is not available (or needed).

Definition at line 221 of file request_handler.hpp.

## generic_request_t() [2/2]

template<typename Extra_Data >
template<typename Extra_Data_Factory >

restinio::generic_request_t< Extra_Data >::generic_request_t | ( | request_id_t | request_id,
|  | http_request_header_t | header,
|  | std::string | body,
|  | chunked_input_info_unique_ptr_t | chunked_input_info,
|  | impl::connection_handle_t | connection,
|  | endpoint_t | remote_endpoint,
|  | Extra_Data_Factory & | extra_data_factory
| ) |  |

inline

New-format initializing constructor.

Since
  v.0.6.9

Definition at line 244 of file request_handler.hpp.

## Member Function Documentation

## body()

template<typename Extra_Data >

const std::string & restinio::generic_request_t< Extra_Data >::body | ( |  | ) | const

inline noexcept

Get request body.

Definition at line 271 of file request_handler.hpp.

## check_connection()

template<typename Extra_Data >

void restinio::generic_request_t< Extra_Data >::check_connection | ( |  | ) |

inline private

Definition at line 402 of file request_handler.hpp.

## chunked_input_info()

template<typename Extra_Data >

nullable_pointer_t< const chunked_input_info_t > restinio::generic_request_t< Extra_Data >::chunked_input_info | ( |  | ) | const

inline noexcept

Get optional info about chunked input.

Note
  nullptr will be returned if chunked-encoding wasn't used in the incoming request.

Since
  v.0.6.9

Definition at line 307 of file request_handler.hpp.

## connection_id()

template<typename Extra_Data >

connection_id_t restinio::generic_request_t< Extra_Data >::connection_id | ( |  | ) | const

inline noexcept

Get connection id.

Definition at line 293 of file request_handler.hpp.

## create_response()

template<typename Extra_Data >
template<typename Output = restinio_controlled_output_t>

auto restinio::generic_request_t< Extra_Data >::create_response | ( | http_status_line_t | status_line = `status_ok()` | ) |

inline

Definition at line 278 of file request_handler.hpp.

## extra_data() [1/2]

template<typename Extra_Data >

RESTINIO_NODISCARD const Extra_Data & restinio::generic_request_t< Extra_Data >::extra_data | ( |  | ) | const

inline noexcept

Get readonly access to extra-data object incorporated into a request object.

Note
  This method is present always but it has the sense only if Extra_Data is not no_extra_data_factory_t::data_t.

Usage example:

struct my_extra_data_factory {
struct data_t {
user_identity user_id_;
...
};
void make_within(restinio::extra_data_buffer_t<data_t> buf) {
new(buf.get()) data_t{};
}
};
struct my_traits : public restinio::default_traits_t {
using extra_data_factory_t = my_extra_data_factory;
};
restinio::request_handling_status_t actual_handler(
const restinio::generic_request_handle_t<my_extra_data_factory::data_t> & req) {
const auto & ud = req->extra_data();
if(ud.user_id_.valid()) {
...
}
else {
...
}
}
restinio::extra_data_buffer_t
Helper for holding a pointer to a buffer where a new object of type Extra_Data should be constructed.
Definition: request_handler.hpp:54
restinio::extra_data_buffer_t::get
RESTINIO_NODISCARD void * get() const noexcept
Definition: request_handler.hpp:62
restinio::generic_request_handle_t
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.
Definition: request_handler.hpp:455
restinio::request_handling_status_t
request_handling_status_t
Request handling status.
Definition: common_types.hpp:26
restinio::traits_t
Definition: traits.hpp:147

Since
  v.0.6.13

Definition at line 395 of file request_handler.hpp.

## extra_data() [2/2]

template<typename Extra_Data >

RESTINIO_NODISCARD Extra_Data & restinio::generic_request_t< Extra_Data >::extra_data | ( |  | ) |

inline noexcept

Get writeable access to extra-data object incorporated into a request object.

Note
  This method is present always but it has the sense only if Extra_Data is not no_extra_data_factory_t::data_t.

Usage example:

struct my_extra_data_factory {
struct data_t {
user_identity user_id_;
...
};
void make_within(restinio::extra_data_buffer_t<data_t> buf) {
new(buf.get()) data_t{};
}
};
struct my_traits : public restinio::default_traits_t {
using extra_data_factory_t = my_extra_data_factory;
};
restinio::request_handling_status_t authentificator(
const restinio::generic_request_handle_t<my_extra_data_factory::data_t> & req) {
auto & ud = req->extra_data();
...
ud.user_id_ = some_calculated_user_id;
}

Since
  v.0.6.13

Definition at line 349 of file request_handler.hpp.

## header()

template<typename Extra_Data >

const http_request_header_t & restinio::generic_request_t< Extra_Data >::header | ( |  | ) | const

inline noexcept

Get request header.

Definition at line 264 of file request_handler.hpp.

## remote_endpoint()

template<typename Extra_Data >

const endpoint_t & restinio::generic_request_t< Extra_Data >::remote_endpoint | ( |  | ) | const

inline noexcept

Get the remote endpoint of the underlying connection.

Definition at line 296 of file request_handler.hpp.

## request_id()

template<typename Extra_Data >

auto restinio::generic_request_t< Extra_Data >::request_id | ( |  | ) | const

inline noexcept

Get request id.

Definition at line 290 of file request_handler.hpp.

## Friends And Related Function Documentation

## impl::access_req_connection

template<typename Extra_Data >
template<typename UD >

impl::connection_handle_t & impl::access_req_connection | ( | generic_request_t< UD > & |  | ) |

friend

## Member Data Documentation

## m_body

template<typename Extra_Data >

const std::string restinio::generic_request_t< Extra_Data >::m_body

private

Definition at line 412 of file request_handler.hpp.

## m_chunked_input_info

template<typename Extra_Data >

const chunked_input_info_unique_ptr_t restinio::generic_request_t< Extra_Data >::m_chunked_input_info

private

Optional description for chunked-encoding.

It is present only if chunked-encoded body is found in the incoming request.

Since
  v.0.6.9

Definition at line 421 of file request_handler.hpp.

## m_connection

template<typename Extra_Data >

impl::connection_handle_t restinio::generic_request_t< Extra_Data >::m_connection

private

Definition at line 423 of file request_handler.hpp.

## m_connection_id

template<typename Extra_Data >

const connection_id_t restinio::generic_request_t< Extra_Data >::m_connection_id

private

Definition at line 424 of file request_handler.hpp.

## m_extra_data_holder

template<typename Extra_Data >

impl::generic_request_extra_data_holder_t< Extra_Data > restinio::generic_request_t< Extra_Data >::m_extra_data_holder

private

An instance of extra-data that is incorporated into a request object.

Since
  v.0.6.13

Definition at line 435 of file request_handler.hpp.

## m_header

template<typename Extra_Data >

const http_request_header_t restinio::generic_request_t< Extra_Data >::m_header

private

Definition at line 411 of file request_handler.hpp.

## m_remote_endpoint

template<typename Extra_Data >

const endpoint_t restinio::generic_request_t< Extra_Data >::m_remote_endpoint

private

Remote endpoint for underlying connection.

Definition at line 427 of file request_handler.hpp.

## m_request_id

template<typename Extra_Data >

const request_id_t restinio::generic_request_t< Extra_Data >::m_request_id

private

Definition at line 410 of file request_handler.hpp.

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

- restinio/request_handler.hpp