userver: server::request::RequestContext Class Reference
Loading...
Searching...
No Matches
server::request::RequestContext Class Referencefinal

#include <userver/server/request/request_context.hpp>

Detailed Description

Public Member Functions

 RequestContext (RequestContext &&) noexcept
 
 RequestContext (const RequestContext &)=delete
 
template<typename Data >
Data & SetUserData (Data data)
 Stores user data if it was not previously stored in this.
 
template<typename Data , typename... Args>
Data & EmplaceUserData (Args &&... args)
 Emplaces user data if it was not previously stored in this.
 
template<typename Data >
Data & GetUserData ()
 
template<typename Data >
const Data & GetUserData () const
 
template<typename Data >
std::remove_reference_t< Data > * GetUserDataOptional ()
 
template<typename Data >
const std::remove_reference_t< Data > * GetUserDataOptional () const
 
void EraseUserData ()
 Erases the user data.
 
template<typename Data >
Data & SetData (std::string name, Data data)
 Stores the data with specified name if it was not previously stored in this.
 
template<typename Data , typename... Args>
Data & EmplaceData (std::string name, Args &&... args)
 Emplaces the data with specified name if it was not previously stored in this.
 
template<typename Data >
Data & GetData (std::string_view name)
 
template<typename Data >
const Data & GetData (std::string_view name) const
 
template<typename Data >
std::remove_reference_t< Data > * GetDataOptional (std::string_view name)
 
template<typename Data >
const std::remove_reference_t< Data > * GetDataOptional (std::string_view name) const
 
void EraseData (std::string_view name)
 Erase data with specified name.
 
impl::InternalRequestContext & GetInternalContext ()
 

Member Function Documentation

◆ EmplaceData()

template<typename Data , typename... Args>
Data & server::request::RequestContext::EmplaceData ( std::string name,
Args &&... args )

Emplaces the data with specified name if it was not previously stored in this.

Exceptions
std::runtime_errorif data with such name was already stored.

Definition at line 187 of file request_context.hpp.

◆ EmplaceUserData()

template<typename Data , typename... Args>
Data & server::request::RequestContext::EmplaceUserData ( Args &&... args)

Emplaces user data if it was not previously stored in this.

Exceptions
std::runtime_errorif user data was already stored.

Definition at line 141 of file request_context.hpp.

◆ EraseData()

void server::request::RequestContext::EraseData ( std::string_view name)
inline

Erase data with specified name.

Definition at line 218 of file request_context.hpp.

◆ EraseUserData()

void server::request::RequestContext::EraseUserData ( )
inline

Erases the user data.

Definition at line 171 of file request_context.hpp.

◆ GetData() [1/2]

template<typename Data >
Data & server::request::RequestContext::GetData ( std::string_view name)
Returns
Stored data with specified name.
Exceptions
std::runtime_errorif no data was stored
std::bad_any_castif data of different type was stored
Examples
samples/postgres_auth/postgres_service.cpp.

Definition at line 194 of file request_context.hpp.

◆ GetData() [2/2]

template<typename Data >
const Data & server::request::RequestContext::GetData ( std::string_view name) const
Returns
Stored data with specified name.
Exceptions
std::runtime_errorif no data was stored
std::bad_any_castif data of different type was stored

Definition at line 199 of file request_context.hpp.

◆ GetDataOptional() [1/2]

template<typename Data >
std::remove_reference_t< Data > * server::request::RequestContext::GetDataOptional ( std::string_view name)
Returns
Stored data with specified name or nullptr if no data found.
Exceptions
std::bad_any_castif data of different type was stored.

Definition at line 205 of file request_context.hpp.

◆ GetDataOptional() [2/2]

template<typename Data >
const std::remove_reference_t< Data > * server::request::RequestContext::GetDataOptional ( std::string_view name) const
Returns
Stored data with specified name or nullptr if no data found.
Exceptions
std::bad_any_castif data of different type was stored.

Definition at line 212 of file request_context.hpp.

◆ GetUserData() [1/2]

template<typename Data >
Data & server::request::RequestContext::GetUserData ( )
Returns
Stored user data
Exceptions
std::runtime_errorif no data was stored
std::bad_any_castif data of different type was stored

Definition at line 148 of file request_context.hpp.

◆ GetUserData() [2/2]

template<typename Data >
const Data & server::request::RequestContext::GetUserData ( ) const
Returns
Stored user data
Exceptions
std::runtime_errorif no data was stored
std::bad_any_castif data of different type was stored

Definition at line 153 of file request_context.hpp.

◆ GetUserDataOptional() [1/2]

template<typename Data >
std::remove_reference_t< Data > * server::request::RequestContext::GetUserDataOptional ( )
Returns
A pointer to data of type Data if it was stored before during current request processing or nullptr otherwise

Definition at line 159 of file request_context.hpp.

◆ GetUserDataOptional() [2/2]

template<typename Data >
const std::remove_reference_t< Data > * server::request::RequestContext::GetUserDataOptional ( ) const
Returns
A pointer to data of type Data if it was stored before during current request processing or nullptr otherwise

Definition at line 165 of file request_context.hpp.

◆ SetData()

template<typename Data >
Data & server::request::RequestContext::SetData ( std::string name,
Data data )

Stores the data with specified name if it was not previously stored in this.

Exceptions
std::runtime_errorif data with such name was already stored.
Examples
samples/postgres_auth/auth_bearer.cpp.

Definition at line 174 of file request_context.hpp.

◆ SetUserData()

template<typename Data >
Data & server::request::RequestContext::SetUserData ( Data data)

Stores user data if it was not previously stored in this.

Exceptions
std::runtime_errorif user data was already stored.

Definition at line 128 of file request_context.hpp.


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