Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Context.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2023, 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 "util/Taggable.hpp"
24#include "util/log/Logger.hpp"
25#include "web/SubscriptionContextInterface.hpp"
26
27#include <boost/asio/spawn.hpp>
28#include <boost/json.hpp>
29#include <boost/json/object.hpp>
30
31#include <cstdint>
32#include <string>
33#include <utility>
34
35namespace web {
36
41 boost::asio::yield_context yield;
42 std::string method;
43 std::uint32_t apiVersion;
44 boost::json::object params;
47 std::string clientIp;
48 bool isAdmin;
49
64 boost::asio::yield_context yield,
65 std::string command,
66 std::uint32_t apiVersion,
67 boost::json::object params,
68 SubscriptionContextPtr subscriptionContext,
69 util::TagDecoratorFactory const& tagFactory,
70 data::LedgerRange const& range,
71 std::string clientIp,
72 bool isAdmin
73 )
74 : Taggable(tagFactory)
75 , yield(std::move(yield))
76 , method(std::move(command))
77 , apiVersion(apiVersion)
78 , params(std::move(params))
79 , session(std::move(subscriptionContext))
80 , range(range)
81 , clientIp(std::move(clientIp))
82 , isAdmin(isAdmin)
83 {
84 static util::Logger const log{"Performance"}; // NOLINT(readability-identifier-naming)
85 LOG(log.debug()) << tag() << "new Context created";
86 }
87
88 Context(Context&&) = default;
89 Context&
90 operator=(Context&&) = default;
91};
92
93} // namespace web
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:110
A factory for TagDecorator instantiation.
Definition Taggable.hpp:169
A base class that allows attaching a tag decorator to a subclass.
Definition Taggable.hpp:240
BaseTagDecorator const & tag() const
Getter for tag decorator.
Definition Taggable.hpp:267
Taggable(util::TagDecoratorFactory const &tagFactory)
New Taggable from a specified factory.
Definition Taggable.hpp:250
This namespace implements the web server and related components.
Definition Types.hpp:43
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
Context that is used by the Webserver to pass around information about an incoming request.
Definition Context.hpp:40
Context(boost::asio::yield_context yield, std::string command, std::uint32_t apiVersion, boost::json::object params, SubscriptionContextPtr subscriptionContext, util::TagDecoratorFactory const &tagFactory, data::LedgerRange const &range, std::string clientIp, bool isAdmin)
Create a new Context instance.
Definition Context.hpp:63