OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::rpc::json_rpc_http_server Class Reference

Asynchrounous HTTP JSON-RPC server implemented using libmicrohttpd and libjsoncpp. More...

#include <json_rpc_http_server.hpp>

Public Types

using result_callback_type = std::function<void(std::optional<Json::Value>)>
 Type alias for the callback function for returning response values to the server.
 
using handler_callback_type
 Callback function type provided by the application for processing requests.
 

Public Member Functions

 json_rpc_http_server (network::endpoint_t endpoint, bool enable_cors=false)
 Construct a new server.
 
 ~json_rpc_http_server ()
 Stop the server.
 
 json_rpc_http_server (const json_rpc_http_server &)=delete
 
auto operator= (const json_rpc_http_server &) -> json_rpc_http_server &=delete
 
 json_rpc_http_server (json_rpc_http_server &&)=delete
 
auto operator= (json_rpc_http_server &&) -> json_rpc_http_server &=delete
 
void register_handler_callback (handler_callback_type handler_callback)
 Register the application request handler function with the server.
 
auto init () -> bool
 Start listening for incoming connections and processing requests.
 

Detailed Description

Asynchrounous HTTP JSON-RPC server implemented using libmicrohttpd and libjsoncpp.

Definition at line 22 of file json_rpc_http_server.hpp.

Member Typedef Documentation

◆ handler_callback_type

Initial value:
std::function<
bool(std::string, Json::Value, result_callback_type)>
std::function< void(std::optional< Json::Value >)> result_callback_type
Type alias for the callback function for returning response values to the server.

Callback function type provided by the application for processing requests.

Definition at line 29 of file json_rpc_http_server.hpp.

◆ result_callback_type

using cbdc::rpc::json_rpc_http_server::result_callback_type = std::function<void(std::optional<Json::Value>)>

Type alias for the callback function for returning response values to the server.

Definition at line 26 of file json_rpc_http_server.hpp.

Constructor & Destructor Documentation

◆ json_rpc_http_server() [1/3]

cbdc::rpc::json_rpc_http_server::json_rpc_http_server ( network::endpoint_t endpoint,
bool enable_cors = false )
explicit

Construct a new server.

Parameters
endpointnetwork endpoint to listen on.
enable_corstrue if CORS should be enabled.

Definition at line 13 of file json_rpc_http_server.cpp.

◆ ~json_rpc_http_server()

cbdc::rpc::json_rpc_http_server::~json_rpc_http_server ( )

Stop the server.

Definition at line 19 of file json_rpc_http_server.cpp.

◆ json_rpc_http_server() [2/3]

cbdc::rpc::json_rpc_http_server::json_rpc_http_server ( const json_rpc_http_server & )
delete

◆ json_rpc_http_server() [3/3]

cbdc::rpc::json_rpc_http_server::json_rpc_http_server ( json_rpc_http_server && )
delete

Member Function Documentation

◆ init()

auto cbdc::rpc::json_rpc_http_server::init ( ) -> bool

Start listening for incoming connections and processing requests.

Returns
true if listening was successful.

Definition at line 51 of file json_rpc_http_server.cpp.

◆ operator=() [1/2]

auto cbdc::rpc::json_rpc_http_server::operator= ( const json_rpc_http_server & ) -> json_rpc_http_server &=delete
delete

◆ operator=() [2/2]

auto cbdc::rpc::json_rpc_http_server::operator= ( json_rpc_http_server && ) -> json_rpc_http_server &=delete
delete

◆ register_handler_callback()

void cbdc::rpc::json_rpc_http_server::register_handler_callback ( handler_callback_type handler_callback)

Register the application request handler function with the server.

Definition at line 278 of file json_rpc_http_server.cpp.


The documentation for this class was generated from the following files: