aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/demo/demo_http_server
diff options
context:
space:
mode:
authorAntonio Juarez <antonio.maria.juarez@live.com>2014-04-07 16:02:15 +0100
committerAntonio Juarez <antonio.maria.juarez@live.com>2014-04-07 16:02:15 +0100
commita401a02ddb3fb045d998cf650292cab3b3ebfd58 (patch)
tree61d021af997193aba90b95b70836c2d031334aff /contrib/epee/demo/demo_http_server
parentjson rpc for wallet and bugfix (diff)
downloadmonero-a401a02ddb3fb045d998cf650292cab3b3ebfd58.tar.xz
Improvements in JSON RPC
Diffstat (limited to 'contrib/epee/demo/demo_http_server')
-rw-r--r--contrib/epee/demo/demo_http_server/demo_http_server.cpp10
-rw-r--r--contrib/epee/demo/demo_http_server/demo_http_server.h12
2 files changed, 12 insertions, 10 deletions
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.cpp b/contrib/epee/demo/demo_http_server/demo_http_server.cpp
index fda53b9ad..85547e4c9 100644
--- a/contrib/epee/demo/demo_http_server/demo_http_server.cpp
+++ b/contrib/epee/demo/demo_http_server/demo_http_server.cpp
@@ -43,7 +43,7 @@ bool communicate(const std::string url, t_request& req, t_response& rsp, const s
{
epee::json_rpc::request<t_request> req_t = AUTO_VAL_INIT(req_t);
req_t.jsonrpc = "2.0";
- req_t.id = "10";
+ req_t.id = epee::serialization::storage_entry(10);
req_t.method = "command_example_1";
req_t.params = req;
epee::json_rpc::response<t_response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
demo::demo_http_server srv;
- start_default_console(&srv);
+ start_default_console(&srv, "#");
std::string bind_param = "0.0.0.0";
std::string port = "83";
@@ -195,7 +195,7 @@ namespace demo
return true;
}
- bool demo_http_server::on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res)
+ bool demo_http_server::on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt)
{
CHECK_AND_ASSERT_MES(req.sub == demo::get_test_data(), false, "wrong request");
res.m_success = true;
@@ -203,14 +203,14 @@ namespace demo
return true;
}
- bool demo_http_server::on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp)
+ bool demo_http_server::on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt)
{
error_resp.code = 232432;
error_resp.message = "bla bla bla";
return false;
}
- bool demo_http_server::on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res)
+ bool demo_http_server::on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt)
{
return true;
}
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.h b/contrib/epee/demo/demo_http_server/demo_http_server.h
index bb8f9bffa..088ead548 100644
--- a/contrib/epee/demo/demo_http_server/demo_http_server.h
+++ b/contrib/epee/demo/demo_http_server/demo_http_server.h
@@ -39,9 +39,11 @@ using namespace epee;
namespace demo
{
- class demo_http_server: public net_utils::http::i_http_server_handler
+ class demo_http_server: public net_utils::http::i_http_server_handler<epee::net_utils::connection_context_base>
{
public:
+ typedef epee::net_utils::connection_context_base connection_context;
+
demo_http_server():m_stop(false){}
bool run();
bool init(const std::string& bind_port = "11112", const std::string& bind_ip = "0.0.0.0");
@@ -52,7 +54,7 @@ namespace demo
private:
- CHAIN_HTTP_TO_MAP2(); //forward http requests to uri map
+ CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
BEGIN_URI_MAP2()
MAP_URI2("/requestr_uri_1", on_requestr_uri_1)
@@ -89,10 +91,10 @@ namespace demo
net_utils::http::http_response_info& response,
const net_utils::connection_context_base& m_conn_context);
- bool on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res);
- bool on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res);
+ bool on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt);
+ bool on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt);
- bool on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp);
+ bool on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt);
net_utils::boosted_http_server_custum_handling m_net_server;
std::atomic<bool> m_stop;