Monero
Loading...
Searching...
No Matches
http_server_handlers_map2.h File Reference
Include dependency graph for http_server_handlers_map2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MONERO_DEFAULT_LOG_CATEGORY   "net.http"
#define CHAIN_HTTP_TO_MAP2(context_type)
#define BEGIN_URI_MAP2()
#define MAP_URI2(pattern, callback)
#define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type)
#define MAP_URI_AUTO_JON2_IF(s_pattern, callback_f, command_type, cond)
#define MAP_URI_AUTO_JON2(s_pattern, callback_f, command_type)
#define MAP_URI_AUTO_BIN2(s_pattern, callback_f, command_type)
#define CHAIN_URI_MAP2(callback)
#define END_URI_MAP2()
#define BEGIN_JSON_RPC_MAP(uri)
#define PREPARE_OBJECTS_FROM_JSON(command_type)
#define FINALIZE_OBJECTS_TO_JSON(method_name)
#define MAP_JON_RPC_WE_IF(method_name, callback_f, command_type, cond)
#define MAP_JON_RPC_WE(method_name, callback_f, command_type)
#define MAP_JON_RPC_WERI(method_name, callback_f, command_type)
#define MAP_JON_RPC(method_name, callback_f, command_type)
#define END_JSON_RPC_MAP()

Macro Definition Documentation

◆ BEGIN_JSON_RPC_MAP

#define BEGIN_JSON_RPC_MAP ( uri)

◆ BEGIN_URI_MAP2

#define BEGIN_URI_MAP2 ( )
Value:
template<class t_context> bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \
t_context& m_conn_context) { \
bool handled = false; \
if(false) return true;
#define true

◆ CHAIN_HTTP_TO_MAP2

#define CHAIN_HTTP_TO_MAP2 ( context_type)
Value:
bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \
context_type& m_conn_context) \
{\
MINFO("HTTP [" << m_conn_context.m_remote_address.host_str() << "] " << query_info.m_http_method_str << " " << query_info.m_URI); \
response.m_response_code = 200; \
response.m_response_comment = "Ok"; \
try \
{ \
if(!handle_http_request_map(query_info, response, m_conn_context)) \
{response.m_response_code = 404;response.m_response_comment = "Not found";} \
} \
catch (const std::exception &e) \
{ \
MERROR(m_conn_context << "Exception in handle_http_request_map: " << e.what()); \
response.m_response_code = 500; \
response.m_response_comment = "Internal Server Error"; \
} \
return true; \
}
e
Definition pymoduletest.py:79

◆ CHAIN_URI_MAP2

#define CHAIN_URI_MAP2 ( callback)
Value:
else {callback(query_info, response_info, m_conn_context);handled = true;}

◆ END_JSON_RPC_MAP

#define END_JSON_RPC_MAP ( )
Value:
rsp.id = id_; \
rsp.jsonrpc = "2.0"; \
rsp.error.code = -32601; \
rsp.error.message = "Method not found"; \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body); \
return true; \
}
response< dummy_result, error > error_response
Definition jsonrpc_structs.h:106
int64_t code
Definition jsonrpc_structs.h:33
std::string message
Definition jsonrpc_structs.h:34
epee::serialization::storage_entry id
Definition jsonrpc_structs.h:61
t_error error
Definition jsonrpc_structs.h:62
std::string jsonrpc
Definition jsonrpc_structs.h:59

◆ END_URI_MAP2

#define END_URI_MAP2 ( )
Value:
return handled;}

◆ FINALIZE_OBJECTS_TO_JSON

#define FINALIZE_OBJECTS_TO_JSON ( method_name)
Value:
epee::serialization::store_t_to_json(resp, response_info.m_body); \
response_info.m_mime_tipe = "application/json"; \
response_info.m_header_info.m_content_type = " application/json"; \
MDEBUG( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms");
uint64_t get_tick_count()
Definition time_helper.h:82
unsigned __int64 uint64_t
Definition stdint.h:136

◆ MAP_JON_RPC

#define MAP_JON_RPC ( method_name,
callback_f,
command_type )
Value:
else if(callback_name == method_name) \
{ \
PREPARE_OBJECTS_FROM_JSON(command_type) \
MINFO(m_conn_context << "calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
{ \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
fail_resp.error.code = -32603; \
fail_resp.error.message = "Internal error"; \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}
const char * res
Definition hmac_keccak.cpp:42
#define AUTO_VAL_INIT(v)
Definition misc_language.h:36

◆ MAP_JON_RPC_WE

#define MAP_JON_RPC_WE ( method_name,
callback_f,
command_type )
Value:
MAP_JON_RPC_WE_IF(method_name, callback_f, command_type, true)
#define MAP_JON_RPC_WE_IF(method_name, callback_f, command_type, cond)
Definition http_server_handlers_map2.h:213

◆ MAP_JON_RPC_WE_IF

#define MAP_JON_RPC_WE_IF ( method_name,
callback_f,
command_type,
cond )
Value:
else if((callback_name == method_name) && (cond)) \
{ \
PREPARE_OBJECTS_FROM_JSON(command_type) \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
MINFO(m_conn_context << "Calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, fail_resp.error, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}

◆ MAP_JON_RPC_WERI

#define MAP_JON_RPC_WERI ( method_name,
callback_f,
command_type )
Value:
else if(callback_name == method_name) \
{ \
PREPARE_OBJECTS_FROM_JSON(command_type) \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
MINFO(m_conn_context << "calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, fail_resp.error, response_info, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}

◆ MAP_URI2

#define MAP_URI2 ( pattern,
callback )
Value:
else if(std::string::npos != query_info.m_URI.find(pattern)) return callback(query_info, response_info, &m_conn_context);

◆ MAP_URI_AUTO_BIN2

#define MAP_URI_AUTO_BIN2 ( s_pattern,
callback_f,
command_type )

◆ MAP_URI_AUTO_JON2

#define MAP_URI_AUTO_JON2 ( s_pattern,
callback_f,
command_type )
Value:
MAP_URI_AUTO_JON2_IF(s_pattern, callback_f, command_type, true)
#define MAP_URI_AUTO_JON2_IF(s_pattern, callback_f, command_type, cond)
Definition http_server_handlers_map2.h:70

◆ MAP_URI_AUTO_JON2_IF

#define MAP_URI_AUTO_JON2_IF ( s_pattern,
callback_f,
command_type,
cond )

◆ MAP_URI_AUTO_XML2

#define MAP_URI_AUTO_XML2 ( s_pattern,
callback_f,
command_type )

◆ MONERO_DEFAULT_LOG_CATEGORY

#define MONERO_DEFAULT_LOG_CATEGORY   "net.http"

◆ PREPARE_OBJECTS_FROM_JSON

#define PREPARE_OBJECTS_FROM_JSON ( command_type)
Value:
handled = true; \
response_info.m_mime_tipe = "application/json"; \
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
if(!req.load(ps)) \
{ \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
fail_resp.error.code = -32602; \
fail_resp.error.message = "Invalid params"; \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
resp.jsonrpc = "2.0"; \
resp.id = req.id;
epee::serialization::portable_storage ps
Definition load_from_binary.cpp:40
Definition jsonrpc_structs.h:15
epee::serialization::storage_entry id
Definition jsonrpc_structs.h:18
Definition jsonrpc_structs.h:58