mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
JSON API accessible via HTTP GET method
This is useful in cases where the client cannot use POST method. /jsonApiServer/shutdown now reply before shutting down the core.
This commit is contained in:
parent
3d476f689f
commit
148e46346d
2 changed files with 39 additions and 5 deletions
|
@ -36,7 +36,13 @@
|
|||
nullptr, 0, \
|
||||
RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); \
|
||||
RsJson& jReq(cReq.mJson); \
|
||||
jReq.Parse(reinterpret_cast<const char*>(body.data()), body.size()); \
|
||||
if(session->get_request()->get_method() == "GET") \
|
||||
{ \
|
||||
const std::string jrqp(session->get_request()->get_query_parameter("jsonData")); \
|
||||
jReq.Parse(jrqp.c_str(), jrqp.size()); \
|
||||
} \
|
||||
else \
|
||||
jReq.Parse(reinterpret_cast<const char*>(body.data()), body.size()); \
|
||||
\
|
||||
RsGenericSerializer::SerializeContext cAns; \
|
||||
RsJson& jAns(cAns.mJson); \
|
||||
|
@ -87,8 +93,15 @@ JsonApiServer::JsonApiServer(
|
|||
registerHandler("/jsonApiServer/shutdown",
|
||||
[this](const std::shared_ptr<rb::Session> session)
|
||||
{
|
||||
session->close(rb::OK);
|
||||
shutdown();
|
||||
size_t reqSize = session->get_request()->get_header("Content-Length", 0);
|
||||
session->fetch( reqSize, [this](
|
||||
const std::shared_ptr<rb::Session> session,
|
||||
const rb::Bytes& body )
|
||||
{
|
||||
INITIALIZE_API_CALL_JSON_CONTEXT;
|
||||
DEFAULT_API_CALL_JSON_RETURN(rb::OK);
|
||||
shutdown();
|
||||
} );
|
||||
});
|
||||
|
||||
registerHandler("/jsonApiServer/version",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue