Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
VersionHandler.hpp
1#pragma once
2
3#include "rpc/common/APIVersion.hpp"
4#include "rpc/common/Types.hpp"
5#include "rpc/common/impl/APIVersionParser.hpp"
6#include "util/config/ConfigDefinition.hpp"
7
8#include <boost/json/conversion.hpp>
9#include <boost/json/value.hpp>
10
11#include <cstdint>
12
13namespace rpc {
14
21
22public:
26 struct Output {
27 uint32_t minVersion;
28 uint32_t maxVersion;
29 uint32_t currVersion;
30 };
31
38 : apiVersionParser_(
39 config.get<uint32_t>("api_version.default"),
40 config.get<uint32_t>("api_version.min"),
41 config.get<uint32_t>("api_version.max")
42 )
43 {
44 }
45
50
57 [[nodiscard]] Result
58 process([[maybe_unused]] Context const& ctx) const
59 {
60 using namespace rpc;
61
62 auto output = Output{};
63 output.currVersion = apiVersionParser_.getDefaultVersion();
64 output.minVersion = apiVersionParser_.getMinVersion();
65 output.maxVersion = apiVersionParser_.getMaxVersion();
66 return output;
67 }
68
69private:
70 friend void
71 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output)
72 {
73 jv = {
74 {
75 "version",
76 {
77 {"first", output.minVersion},
78 {"last", output.maxVersion},
79 {"good", output.currVersion},
80 },
81 },
82 };
83 }
84};
85
86} // namespace rpc
Result process(Context const &ctx) const
Process the version command.
Definition VersionHandler.hpp:58
VersionHandler(util::config::ClioConfigDefinition const &config)
Construct a new Version Handler object.
Definition VersionHandler.hpp:37
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition VersionHandler.hpp:49
Definition APIVersionParser.hpp:15
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:63
void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, BookChange const &change)
Implementation of value_from for BookChange type.
Definition BookChangesHelper.hpp:233
Context of an RPC call.
Definition Types.hpp:102
A struct to hold the output data of the command.
Definition VersionHandler.hpp:26
uint32_t currVersion
Default API version.
Definition VersionHandler.hpp:29
uint32_t minVersion
Minimum supported API version.
Definition VersionHandler.hpp:27
uint32_t maxVersion
Maximum supported API version.
Definition VersionHandler.hpp:28