Represents an HTTP or WebSocket request.
More...
#include <Request.hpp>
|
enum class | Method { Get
, Post
, Websocket
, Unsupported
} |
| Method of the request. More...
|
|
using | HttpHeaders = boost::beast::http::request<boost::beast::http::string_body>::header_type |
| The headers of an HTTP request.
|
|
|
| Request (boost::beast::http::request< boost::beast::http::string_body > request) |
| Construct from an HTTP request.
|
|
| Request (std::string request, HttpHeaders const &headers) |
| Construct from a WebSocket request.
|
|
Method | method () const |
| Get the method of the request.
|
|
bool | isHttp () const |
| Check if the request is an HTTP request.
|
|
std::optional< std::reference_wrapper< boost::beast::http::request< boost::beast::http::string_body > const > > | asHttpRequest () const |
| Get the HTTP request.
|
|
std::string_view | message () const |
| Get the body (in case of an HTTP request) or the message (in case of a WebSocket request).
|
|
std::optional< std::string_view > | target () const |
| Get the target of the request.
|
|
HttpHeaders const & | httpHeaders () const |
| Get the headers of the request.
|
|
std::optional< std::string_view > | headerValue (boost::beast::http::field headerName) const |
| Get the value of a header.
|
|
std::optional< std::string_view > | headerValue (std::string const &headerName) const |
| Get the value of a header.
|
|
Represents an HTTP or WebSocket request.
◆ Method
Method of the request.
- Note
- Websocket is not a real method, it is used to distinguish WebSocket requests from HTTP requests.
◆ Request() [1/2]
web::ng::Request::Request |
( |
boost::beast::http::request< boost::beast::http::string_body > | request | ) |
|
|
explicit |
Construct from an HTTP request.
- Parameters
-
◆ Request() [2/2]
web::ng::Request::Request |
( |
std::string | request, |
|
|
HttpHeaders const & | headers ) |
Construct from a WebSocket request.
- Parameters
-
request | The WebSocket request. |
headers | The headers of the HTTP request initiated the WebSocket connection |
◆ asHttpRequest()
std::optional< std::reference_wrapper< boost::beast::http::request< boost::beast::http::string_body > const > > web::ng::Request::asHttpRequest |
( |
| ) |
const |
Get the HTTP request.
- Returns
- The HTTP request or std::nullopt if the request is a WebSocket request.
◆ headerValue() [1/2]
std::optional< std::string_view > web::ng::Request::headerValue |
( |
boost::beast::http::field | headerName | ) |
const |
Get the value of a header.
- Parameters
-
headerName | The name of the header. |
- Returns
- The value of the header or std::nullopt if the header does not exist.
◆ headerValue() [2/2]
std::optional< std::string_view > web::ng::Request::headerValue |
( |
std::string const & | headerName | ) |
const |
Get the value of a header.
- Parameters
-
headerName | The name of the header. |
- Returns
- The value of the header or std::nullopt if the header does not exist.
◆ httpHeaders()
Get the headers of the request.
- Returns
- The headers of the request.
◆ isHttp()
bool web::ng::Request::isHttp |
( |
| ) |
const |
Check if the request is an HTTP request.
- Returns
- true if the request is an HTTP request, false otherwise.
◆ message()
std::string_view web::ng::Request::message |
( |
| ) |
const |
Get the body (in case of an HTTP request) or the message (in case of a WebSocket request).
- Returns
- The message of the request.
◆ method()
Get the method of the request.
- Returns
- The method of the request.
◆ target()
std::optional< std::string_view > web::ng::Request::target |
( |
| ) |
const |
Get the target of the request.
- Returns
- The target of the request or std::nullopt if the request is a WebSocket request.
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/web/ng/Request.hpp
- /__w/clio/clio/src/web/ng/Request.cpp