xrpld
Loading...
Searching...
No Matches
Version.h
1#pragma once
2
3#include <xrpld/app/main/Application.h> // IWYU pragma: keep
4#include <xrpld/rpc/Context.h>
5
6#include <xrpl/json/json_value.h>
7#include <xrpl/protocol/ApiVersion.h>
8
9#include <rpcspec/Errors.hpp>
10
11#include <cstdint>
12#include <expected>
13#include <functional>
14
15namespace xrpl::rpc {
16
21{
22public:
31
37 explicit VersionHandler(JsonContext& context) : context_(context)
38 {
39 }
40
46 [[nodiscard]] std::expected<Output, ::rpc::Status>
47 process() const
48 {
49 return Output{
50 .apiVersion = context_.get().apiVersion,
51 .betaEnabled = context_.get().app.config().betaRpcApi,
52 };
53 }
54
61 static void
62 writeResult(json::Value& obj, Output const& output)
63 {
64 setVersion(obj, output.apiVersion, output.betaEnabled);
65 }
66
67private:
69};
70
71} // namespace xrpl::rpc
Represents a JSON value.
Definition json_value.h:121
std::expected< Output, ::rpc::Status > process() const
Process the request.
Definition Version.h:47
VersionHandler(JsonContext &context)
Construct a handler for a single request.
Definition Version.h:37
static void writeResult(json::Value &obj, Output const &output)
Write the output of process() into the response.
Definition Version.h:62
std::reference_wrapper< JsonContext > context_
Definition Version.h:68
The api_version numbers this server serves.
Definition ApiVersion.h:26
void setVersion(json::Value &parent, unsigned int apiVersion, bool betaEnabled)
Definition ApiVersion.h:61
The data a version request produces, written out by writeResult().
Definition Version.h:27
std::uint32_t apiVersion
The API version of the request.
Definition Version.h:28
bool betaEnabled
Whether the beta API version is enabled.
Definition Version.h:29