Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Types.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <boost/beast/core/error.hpp>
23#include <boost/beast/http/field.hpp>
24
25#include <optional>
26#include <string>
27#include <variant>
28
29namespace util::requests {
30
35 std::string message_;
36 std::optional<boost::beast::error_code> errorCode_;
37
38public:
44 explicit RequestError(std::string message);
45
52 RequestError(std::string message, boost::beast::error_code errorCode);
53
57 std::string const&
58 message() const;
59
63 std::optional<boost::beast::error_code> const&
64 errorCode() const;
65};
66
70struct HttpHeader {
77 HttpHeader(boost::beast::http::field name, std::string value);
78
85 HttpHeader(std::string name, std::string value);
86
87 std::variant<boost::beast::http::field, std::string> name;
88 std::string value;
89};
90
91} // namespace util::requests
Error type for HTTP requests.
Definition Types.hpp:34
std::string const & message() const
Definition Types.cpp:49
RequestError(std::string message)
Construct a new Request Error object.
Definition Types.cpp:33
std::optional< boost::beast::error_code > const & errorCode() const
Definition Types.cpp:55
HTTP header.
Definition Types.hpp:70
HttpHeader(boost::beast::http::field name, std::string value)
Construct a new Http Header object.
Definition Types.cpp:60