Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
APIVersion.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 <boost/json.hpp>
23#include <boost/json/object.hpp>
24
25#include <cstdint>
26#include <expected>
27
28namespace rpc {
29
33static constexpr uint32_t kAPI_VERSION_DEFAULT = 1u;
34
38static constexpr uint32_t kAPI_VERSION_MIN = 1u;
39
43static constexpr uint32_t kAPI_VERSION_MAX = 3u;
44
49public:
50 virtual ~APIVersionParser() = default;
51
58 std::expected<uint32_t, std::string> virtual parse(boost::json::object const& request) const = 0;
59};
60
61} // namespace rpc
A baseclass for API version helper.
Definition APIVersion.hpp:48
virtual std::expected< uint32_t, std::string > parse(boost::json::object const &request) const =0
Extracts API version information from a JSON object.
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:36
static constexpr uint32_t kAPI_VERSION_MIN
Minimum API version supported by this build.
Definition APIVersion.hpp:38
static constexpr uint32_t kAPI_VERSION_MAX
Maximum API version supported by this build.
Definition APIVersion.hpp:43
static constexpr uint32_t kAPI_VERSION_DEFAULT
Default API version to use if no version is specified by clients.
Definition APIVersion.hpp:33