Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
httpc.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "config.hpp"
4
5namespace sysio { namespace client { namespace http {
6
7 namespace detail {
8 class http_context_impl;
9
11 void operator()(http_context_impl*) const;
12 };
13 }
14
15 using http_context = std::unique_ptr<detail::http_context_impl, detail::http_context_deleter>;
16
18
19 struct parsed_url {
20 string scheme;
21 string server;
22 string port;
23 string path;
24
25 static string normalize_path(const string& path);
26
27 parsed_url operator+ (string sub_path) {
28 return {scheme, server, port, path + sub_path};
29 }
30 };
31
32 parsed_url parse_url( const string& server_url );
33
35 resolved_url( const parsed_url& url, vector<string>&& resolved_addresses, uint16_t resolved_port, bool is_loopback)
38 ,resolved_port(resolved_port)
39 ,is_loopback(is_loopback)
40 {
41 }
42
43 //used for unix domain, where resolving and ports are nonapplicable
45
48 bool is_loopback = false;
49 };
50
52 const parsed_url& url );
53
58 std::vector<string>& headers;
59
61 const resolved_url& url,
62 bool verify,
63 std::vector<string>& h) : context(context),url(url), headers(h) {
64 verify_cert = verify;
65 }
66
68 const parsed_url& url,
69 bool verify,
70 std::vector<string>& h) : context(context),url(resolve_url(context, url)), headers(h) {
71 verify_cert = verify;
72 }
73 };
74
75 fc::variant do_http_call(
76 const connection_param& cp,
77 const fc::variant& postdata = fc::variant(),
78 bool print_request = false,
79 bool print_response = false);
80
81 const string chain_func_base = "/v1/chain";
82 const string get_info_func = chain_func_base + "/get_info";
83 const string get_transaction_status_func = chain_func_base + "/get_transaction_status";
84 const string send_txn_func = chain_func_base + "/send_transaction";
85 const string push_txn_func = chain_func_base + "/push_transaction";
86 const string send2_txn_func = chain_func_base + "/send_transaction2";
87 const string compute_txn_func = chain_func_base + "/compute_transaction";
88 const string push_txns_func = chain_func_base + "/push_transactions";
89 const string json_to_bin_func = chain_func_base + "/abi_json_to_bin";
90 const string get_block_func = chain_func_base + "/get_block";
91 const string get_block_info_func = chain_func_base + "/get_block_info";
92 const string get_block_header_state_func = chain_func_base + "/get_block_header_state";
93 const string get_account_func = chain_func_base + "/get_account";
94 const string get_table_func = chain_func_base + "/get_table_rows";
95 const string get_table_by_scope_func = chain_func_base + "/get_table_by_scope";
96 const string get_code_func = chain_func_base + "/get_code";
97 const string get_code_hash_func = chain_func_base + "/get_code_hash";
98 const string get_abi_func = chain_func_base + "/get_abi";
99 const string get_raw_abi_func = chain_func_base + "/get_raw_abi";
100 const string get_raw_code_and_abi_func = chain_func_base + "/get_raw_code_and_abi";
101 const string get_currency_balance_func = chain_func_base + "/get_currency_balance";
102 const string get_currency_stats_func = chain_func_base + "/get_currency_stats";
103 const string get_producers_func = chain_func_base + "/get_producers";
104 const string get_schedule_func = chain_func_base + "/get_producer_schedule";
105 const string get_required_keys = chain_func_base + "/get_required_keys";
106
107 const string history_func_base = "/v1/history";
108 const string trace_api_func_base = "/v1/trace_api";
109 const string get_actions_func = history_func_base + "/get_actions";
110 const string get_transaction_trace_func = trace_api_func_base + "/get_transaction_trace";
111 const string get_block_trace_func = trace_api_func_base + "/get_block";
112 const string get_transaction_func = history_func_base + "/get_transaction";
113 const string get_key_accounts_func = history_func_base + "/get_key_accounts";
114 const string get_controlled_accounts_func = history_func_base + "/get_controlled_accounts";
115
116 const string net_func_base = "/v1/net";
117 const string net_connect = net_func_base + "/connect";
118 const string net_disconnect = net_func_base + "/disconnect";
119 const string net_status = net_func_base + "/status";
120 const string net_connections = net_func_base + "/connections";
121
122
123 const string wallet_func_base = "/v1/wallet";
124 const string wallet_create = wallet_func_base + "/create";
125 const string wallet_open = wallet_func_base + "/open";
126 const string wallet_list = wallet_func_base + "/list_wallets";
127 const string wallet_list_keys = wallet_func_base + "/list_keys";
128 const string wallet_public_keys = wallet_func_base + "/get_public_keys";
129 const string wallet_lock = wallet_func_base + "/lock";
130 const string wallet_lock_all = wallet_func_base + "/lock_all";
131 const string wallet_unlock = wallet_func_base + "/unlock";
132 const string wallet_import_key = wallet_func_base + "/import_key";
133 const string wallet_remove_key = wallet_func_base + "/remove_key";
134 const string wallet_create_key = wallet_func_base + "/create_key";
135 const string wallet_sign_trx = wallet_func_base + "/sign_transaction";
136 const string kiod_stop = "/v1/" + string(client::config::key_store_executable_name) + "/stop";
137
138 FC_DECLARE_EXCEPTION( connection_exception, 1100000, "Connection Exception" );
139 }}}
const CBigNum operator+(const CBigNum &a, const CBigNum &b)
Definition base58.cpp:429
wraps boost::filesystem::path to provide platform independent path manipulation.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
websocketpp::server< websocketpp::config::asio > server
#define FC_DECLARE_EXCEPTION(TYPE, CODE, WHAT)
void verify(const char *msg, const T &a, const S &b)
Definition minitest.cpp:13
std::string string
Definition string.hpp:10
Definition name.hpp:106
const string get_raw_code_and_abi_func
Definition httpc.hpp:100
const string get_controlled_accounts_func
Definition httpc.hpp:114
const string get_transaction_status_func
Definition httpc.hpp:83
const string wallet_lock
Definition httpc.hpp:129
const string wallet_sign_trx
Definition httpc.hpp:135
const string get_schedule_func
Definition httpc.hpp:104
const string get_producers_func
Definition httpc.hpp:103
const string get_key_accounts_func
Definition httpc.hpp:113
const string send_txn_func
Definition httpc.hpp:84
const string get_currency_stats_func
Definition httpc.hpp:102
const string net_connect
Definition httpc.hpp:117
const string trace_api_func_base
Definition httpc.hpp:108
const string get_code_hash_func
Definition httpc.hpp:97
const string get_info_func
Definition httpc.hpp:82
const string wallet_public_keys
Definition httpc.hpp:128
const string wallet_remove_key
Definition httpc.hpp:133
const string get_block_trace_func
Definition httpc.hpp:111
const string get_account_func
Definition httpc.hpp:93
std::unique_ptr< detail::http_context_impl, detail::http_context_deleter > http_context
Definition httpc.hpp:15
const string get_code_func
Definition httpc.hpp:96
const string net_connections
Definition httpc.hpp:120
const string get_abi_func
Definition httpc.hpp:98
const string chain_func_base
Definition httpc.hpp:81
const string get_actions_func
Definition httpc.hpp:109
const string wallet_list
Definition httpc.hpp:126
const string wallet_create_key
Definition httpc.hpp:134
const string wallet_import_key
Definition httpc.hpp:132
const string get_table_func
Definition httpc.hpp:94
const string get_currency_balance_func
Definition httpc.hpp:101
http_context create_http_context()
Definition httpc.cpp:43
const string wallet_open
Definition httpc.hpp:125
const string push_txn_func
Definition httpc.hpp:85
const string get_block_header_state_func
Definition httpc.hpp:92
const string get_transaction_func
Definition httpc.hpp:112
const string wallet_unlock
Definition httpc.hpp:131
const string get_transaction_trace_func
Definition httpc.hpp:110
const string wallet_list_keys
Definition httpc.hpp:127
const string net_disconnect
Definition httpc.hpp:118
const string send2_txn_func
Definition httpc.hpp:86
const string push_txns_func
Definition httpc.hpp:88
const string get_block_info_func
Definition httpc.hpp:91
const string wallet_func_base
Definition httpc.hpp:123
const string get_table_by_scope_func
Definition httpc.hpp:95
const string kiod_stop
Definition httpc.hpp:136
const string compute_txn_func
Definition httpc.hpp:87
const string get_raw_abi_func
Definition httpc.hpp:99
const string wallet_create
Definition httpc.hpp:124
const string json_to_bin_func
Definition httpc.hpp:89
const string net_func_base
Definition httpc.hpp:116
const string history_func_base
Definition httpc.hpp:107
const string wallet_lock_all
Definition httpc.hpp:130
const string net_status
Definition httpc.hpp:119
const string get_block_func
Definition httpc.hpp:90
resolved_url resolve_url(const http_context &context, const parsed_url &url)
Definition httpc.cpp:138
const string get_required_keys
Definition httpc.hpp:105
bool print_request
Definition main.cpp:187
bool print_response
Definition main.cpp:188
vector< string > headers
Definition main.cpp:170
unsigned short uint16_t
Definition stdint.h:125
connection_param(const http_context &context, const parsed_url &url, bool verify, std::vector< string > &h)
Definition httpc.hpp:67
std::vector< string > & headers
Definition httpc.hpp:58
const http_context & context
Definition httpc.hpp:55
connection_param(const http_context &context, const resolved_url &url, bool verify, std::vector< string > &h)
Definition httpc.hpp:60
void operator()(http_context_impl *) const
Definition httpc.cpp:38
static string normalize_path(const string &path)
resolved_url(const parsed_url &url)
Definition httpc.hpp:44
resolved_url(const parsed_url &url, vector< string > &&resolved_addresses, uint16_t resolved_port, bool is_loopback)
Definition httpc.hpp:35
vector< string > resolved_addresses
Definition httpc.hpp:46