Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Factories.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2022, 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 "data/Types.hpp"
23#include "rpc/Errors.hpp"
24#include "rpc/common/APIVersion.hpp"
25#include "util/Taggable.hpp"
26#include "web/Context.hpp"
27#include "web/SubscriptionContextInterface.hpp"
28
29#include <boost/asio/spawn.hpp>
30#include <boost/json.hpp>
31#include <boost/json/object.hpp>
32
33#include <expected>
34#include <functional>
35#include <string>
36
37/*
38 * This file contains various classes necessary for executing RPC handlers.
39 * Context gives the handlers access to various other parts of the application Status is used to report errors.
40 * And lastly, there are various functions for making Contexts, Statuses and serializing Status to JSON.
41 * This file is meant to contain any class or function that code outside of the rpc folder needs to use.
42 * For helper functions or classes used within the rpc folder, use RPCHelpers.h.
43 */
44namespace rpc {
45
59std::expected<web::Context, Status>
61 boost::asio::yield_context yc,
62 boost::json::object const& request,
64 util::TagDecoratorFactory const& tagFactory,
65 data::LedgerRange const& range,
66 std::string const& clientIp,
67 std::reference_wrapper<APIVersionParser const> apiVersionParser,
68 bool isAdmin
69);
70
83std::expected<web::Context, Status>
85 boost::asio::yield_context yc,
86 boost::json::object const& request,
87 util::TagDecoratorFactory const& tagFactory,
88 data::LedgerRange const& range,
89 std::string const& clientIp,
90 std::reference_wrapper<APIVersionParser const> apiVersionParser,
91 bool isAdmin
92);
93
94} // namespace rpc
A factory for TagDecorator instantiation.
Definition Taggable.hpp:169
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:36
std::expected< web::Context, Status > makeWsContext(boost::asio::yield_context yc, boost::json::object const &request, web::SubscriptionContextPtr session, util::TagDecoratorFactory const &tagFactory, data::LedgerRange const &range, std::string const &clientIp, std::reference_wrapper< APIVersionParser const > apiVersionParser, bool isAdmin)
A factory function that creates a Websocket context.
Definition Factories.cpp:47
std::expected< web::Context, Status > makeHttpContext(boost::asio::yield_context yc, boost::json::object const &request, util::TagDecoratorFactory const &tagFactory, data::LedgerRange const &range, std::string const &clientIp, std::reference_wrapper< APIVersionParser const > apiVersionParser, bool const isAdmin)
A factory function that creates a HTTP context.
Definition Factories.cpp:77
std::shared_ptr< SubscriptionContextInterface > SubscriptionContextPtr
An alias for shared pointer to a SubscriptionContextInterface.
Definition SubscriptionContextInterface.hpp:86
Stores a range of sequences as a min and max pair.
Definition Types.hpp:247