aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/http_server_handlers_map2.h
diff options
context:
space:
mode:
authorAntonio Juarez <antonio.maria.juarez@live.com>2014-03-20 11:46:11 +0000
committerAntonio Juarez <antonio.maria.juarez@live.com>2014-03-20 11:46:11 +0000
commit8efa1313f3614f34ac0bac947314bb53e9a2412b (patch)
tree2752f8e6dfbb75bc53d56ea422482a8ec5870ffa /contrib/epee/include/net/http_server_handlers_map2.h
parentmoved all stuff to github (diff)
downloadmonero-8efa1313f3614f34ac0bac947314bb53e9a2412b.tar.xz
some fixes
Diffstat (limited to 'contrib/epee/include/net/http_server_handlers_map2.h')
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index 7a8bdd4ad..80c32e3c5 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -31,9 +31,9 @@
#include "http_base.h"
-#define CHAIN_HTTP_TO_MAP2() bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \
+#define CHAIN_HTTP_TO_MAP2(context_type) bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \
epee::net_utils::http::http_response_info& response, \
- const epee::net_utils::connection_context_base& m_conn_context) \
+ context_type& m_conn_context) \
{\
LOG_PRINT_L2("HTTP [" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "] " << query_info.m_http_method_str << " " << query_info.m_URI); \
response.m_response_code = 200; \
@@ -44,9 +44,9 @@
}
-#define BEGIN_URI_MAP2() bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \
+#define BEGIN_URI_MAP2() template<class t_context> bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \
epee::net_utils::http::http_response_info& response_info, \
- const epee::net_utils::connection_context_base& m_conn_context) { \
+ t_context& m_conn_context) { \
bool handled = false; \
if(false) return true; //just a stub to have "else if"
@@ -58,22 +58,22 @@
else if(query_info.m_URI == s_pattern) \
{ \
handled = true; \
- boost::uint64_t ticks = misc_utils::get_tick_count(); \
+ uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_json(static_cast<command_type::request&>(req), query_info.m_body); \
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse json: \r\n" << query_info.m_body); \
- boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
- if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \
+ if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), m_conn_context)) \
{ \
LOG_ERROR("Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \
response_info.m_response_comment = "Internal Server Error"; \
return true; \
} \
- boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
epee::serialization::store_t_to_json(static_cast<command_type::response&>(resp), response_info.m_body); \
- boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
response_info.m_mime_tipe = "application/json"; \
response_info.m_header_info.m_content_type = " application/json"; \
LOG_PRINT( s_pattern << " processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
@@ -83,22 +83,22 @@
else if(query_info.m_URI == s_pattern) \
{ \
handled = true; \
- boost::uint64_t ticks = misc_utils::get_tick_count(); \
+ uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_binary(static_cast<command_type::request&>(req), query_info.m_body); \
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \
- boost::uint64_t ticks1 = misc_utils::get_tick_count(); \
+ uint64_t ticks1 = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
- if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \
+ if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), m_conn_context)) \
{ \
LOG_ERROR("Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \
response_info.m_response_comment = "Internal Server Error"; \
return true; \
} \
- boost::uint64_t ticks2 = misc_utils::get_tick_count(); \
+ uint64_t ticks2 = misc_utils::get_tick_count(); \
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), response_info.m_body); \
- boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
response_info.m_mime_tipe = " application/octet-stream"; \
response_info.m_header_info.m_content_type = " application/octet-stream"; \
LOG_PRINT( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
@@ -170,7 +170,7 @@ namespace epee
#define BEGIN_JSON_RPC_MAP(uri) else if(query_info.m_URI == uri) \
{ \
- boost::uint64_t ticks = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks = epee::misc_utils::get_tick_count(); \
epee::serialization::portable_storage ps; \
if(!ps.load_from_json(query_info.m_body)) \
{ \
@@ -198,20 +198,20 @@ namespace epee
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
req.load(ps); \
- boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
resp.id = req.id; \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.id = req.id; \
- if(!callback_f(req.params, resp.result, fail_resp.error)) \
+ if(!callback_f(req.params, resp.result, fail_resp.error, m_conn_context)) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
- boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
epee::serialization::store_t_to_json(resp, response_info.m_body); \
- boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
response_info.m_mime_tipe = "application/json"; \
response_info.m_header_info.m_content_type = " application/json"; \
LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
@@ -226,11 +226,11 @@ namespace epee
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
req.load(ps); \
- boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
resp.id = req.id; \
- if(!callback_f(req.params, resp.result)) \
+ if(!callback_f(req.params, resp.result, m_conn_context)) \
{ \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.id = req.id; \
@@ -239,9 +239,9 @@ namespace epee
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
- boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
epee::serialization::store_t_to_json(resp, response_info.m_body); \
- boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
response_info.m_mime_tipe = "application/json"; \
response_info.m_header_info.m_content_type = " application/json"; \
LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \