Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Request.hpp
1
#pragma once
2
3
#include <boost/beast/http/field.hpp>
4
#include <boost/beast/http/message.hpp>
5
#include <boost/beast/http/string_body.hpp>
6
7
#include <functional>
8
#include <optional>
9
#include <string>
10
#include <string_view>
11
#include <variant>
12
13
namespace
web::ng {
14
18
class
Request
{
19
public
:
23
using
HttpHeaders
= boost::beast::http::request<boost::beast::http::string_body>::header_type;
24
25
private
:
26
struct
WsData {
27
std::string request;
28
std::reference_wrapper<HttpHeaders const> headers;
29
};
30
31
using
HttpRequest = boost::beast::http::request<boost::beast::http::string_body>;
32
std::variant<HttpRequest, WsData> data_;
33
34
public
:
40
explicit
Request
(boost::beast::http::request<boost::beast::http::string_body> request);
41
48
Request
(std::string request,
HttpHeaders
const
& headers);
49
55
enum class
Method
{ Get, Post, Websocket, Unsupported };
56
62
[[nodiscard]]
Method
63
method
()
const
;
64
70
[[nodiscard]]
bool
71
isHttp
()
const
;
72
78
[[nodiscard]] std::optional<
79
std::reference_wrapper<boost::beast::http::request<boost::beast::http::string_body>
const
>>
80
asHttpRequest
()
const
;
81
88
[[nodiscard]] std::string_view
89
message
()
const
;
90
96
[[nodiscard]] std::optional<std::string_view>
97
target
()
const
;
98
104
[[nodiscard]]
HttpHeaders
const
&
105
httpHeaders
()
const
;
106
113
[[nodiscard]] std::optional<std::string_view>
114
headerValue
(boost::beast::http::field headerName)
const
;
115
122
[[nodiscard]] std::optional<std::string_view>
123
headerValue
(std::string
const
& headerName)
const
;
124
125
private
:
133
[[nodiscard]] HttpRequest
const
&
134
httpRequest()
const
;
135
};
136
137
}
// namespace web::ng
web::ng::Request::httpHeaders
HttpHeaders const & httpHeaders() const
Get the headers of the request.
Definition
Request.cpp:91
web::ng::Request::asHttpRequest
std::optional< std::reference_wrapper< boost::beast::http::request< boost::beast::http::string_body > const > > asHttpRequest() const
Get the HTTP request.
Definition
Request.cpp:65
web::ng::Request::method
Method method() const
Get the method of the request.
Definition
Request.cpp:42
web::ng::Request::headerValue
std::optional< std::string_view > headerValue(boost::beast::http::field headerName) const
Get the value of a header.
Definition
Request.cpp:103
web::ng::Request::Request
Request(boost::beast::http::request< boost::beast::http::string_body > request)
Construct from an HTTP request.
Definition
Request.cpp:31
web::ng::Request::message
std::string_view message() const
Get the body (in case of an HTTP request) or the message (in case of a WebSocket request).
Definition
Request.cpp:74
web::ng::Request::Method
Method
Method of the request.
Definition
Request.hpp:55
web::ng::Request::target
std::optional< std::string_view > target() const
Get the target of the request.
Definition
Request.cpp:82
web::ng::Request::HttpHeaders
boost::beast::http::request< boost::beast::http::string_body >::header_type HttpHeaders
The headers of an HTTP request.
Definition
Request.hpp:23
web::ng::Request::isHttp
bool isHttp() const
Check if the request is an HTTP request.
Definition
Request.cpp:58
src
web
ng
Request.hpp
Generated by
1.17.0