HTTP subsystem refactoring.
This commit is contained in:
parent
5486300db7
commit
cad5fef1ea
25 changed files with 474 additions and 216 deletions
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,12 +27,40 @@
|
|||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
void xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms)
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *k2_0 = "2.0";
|
||||
static const char *kId = "id";
|
||||
static const char *kJsonRPC = "jsonrpc";
|
||||
static const char *kMethod = "method";
|
||||
const char *JsonRequest::kParams = "params";
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
rapidjson::Document xmrig::JsonRequest::create(int64_t id, const char *method)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
Document doc(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("id", id, allocator);
|
||||
doc.AddMember("jsonrpc", "2.0", allocator);
|
||||
doc.AddMember("method", rapidjson::StringRef(method), allocator);
|
||||
doc.AddMember("params", params, allocator);
|
||||
doc.AddMember(StringRef(kId), id, allocator);
|
||||
doc.AddMember(StringRef(kJsonRPC), StringRef(k2_0), allocator);
|
||||
doc.AddMember(StringRef(kMethod), StringRef(method), allocator);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value ¶ms)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
doc.AddMember(StringRef(kId), id, allocator);
|
||||
doc.AddMember(StringRef(kJsonRPC), StringRef(k2_0), allocator);
|
||||
doc.AddMember(StringRef(kMethod), StringRef(method), allocator);
|
||||
doc.AddMember(StringRef(kParams), params, allocator);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue