Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
std::string strHex = | std::string strHex = | ||||
HexStr(ssHeader.begin(), ssHeader.end()) + "\n"; | HexStr(ssHeader.begin(), ssHeader.end()) + "\n"; | ||||
req->WriteHeader("Content-Type", "text/plain"); | req->WriteHeader("Content-Type", "text/plain"); | ||||
req->WriteReply(HTTP_OK, strHex); | req->WriteReply(HTTP_OK, strHex); | ||||
return true; | return true; | ||||
} | } | ||||
case RF_JSON: { | case RF_JSON: { | ||||
UniValue jsonHeaders(UniValue::VARR); | UniValue jsonHeaders(UniValue::VARR); | ||||
{ | |||||
LOCK(cs_main); | |||||
for (const CBlockIndex *pindex : headers) { | for (const CBlockIndex *pindex : headers) { | ||||
jsonHeaders.push_back(blockheaderToJSON(pindex)); | jsonHeaders.push_back(blockheaderToJSON(pindex)); | ||||
} | } | ||||
} | |||||
std::string strJSON = jsonHeaders.write() + "\n"; | std::string strJSON = jsonHeaders.write() + "\n"; | ||||
req->WriteHeader("Content-Type", "application/json"); | req->WriteHeader("Content-Type", "application/json"); | ||||
req->WriteReply(HTTP_OK, strJSON); | req->WriteReply(HTTP_OK, strJSON); | ||||
return true; | return true; | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
"output format not found (available: .bin, .hex)"); | "output format not found (available: .bin, .hex)"); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
case RF_HEX: { | case RF_HEX: { | ||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()) + "\n"; | std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()) + "\n"; | ||||
req->WriteHeader("Content-Type", "text/plain"); | req->WriteHeader("Content-Type", "text/plain"); | ||||
req->WriteReply(HTTP_OK, strHex); | req->WriteReply(HTTP_OK, strHex); | ||||
return true; | return true; | ||||
} | } | ||||
case RF_JSON: { | case RF_JSON: { | ||||
UniValue objBlock = | UniValue objBlock; | ||||
{ | |||||
LOCK(cs_main); | |||||
objBlock = | |||||
blockToJSON(config, block, pblockindex, showTxDetails); | blockToJSON(config, block, pblockindex, showTxDetails); | ||||
} | |||||
std::string strJSON = objBlock.write() + "\n"; | std::string strJSON = objBlock.write() + "\n"; | ||||
req->WriteHeader("Content-Type", "application/json"); | req->WriteHeader("Content-Type", "application/json"); | ||||
req->WriteReply(HTTP_OK, strJSON); | req->WriteReply(HTTP_OK, strJSON); | ||||
return true; | return true; | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
▲ Show 20 Lines • Show All 419 Lines • Show Last 20 Lines |