Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
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)"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_block(const Config &config, HTTPRequest *req, | static bool rest_block(const Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart, bool showTxDetails) { | const std::string &strURIPart, bool showTxDetails) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
"output format not found (available: " + | "output format not found (available: " + | ||||
AvailableDataFormatsString() + ")"); | AvailableDataFormatsString() + ")"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_block_extended(Config &config, HTTPRequest *req, | static bool rest_block_extended(Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
return rest_block(config, req, strURIPart, true); | return rest_block(config, req, strURIPart, true); | ||||
} | } | ||||
static bool rest_block_notxdetails(Config &config, HTTPRequest *req, | static bool rest_block_notxdetails(Config &config, HTTPRequest *req, | ||||
Show All 20 Lines | switch (rf) { | ||||
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: json)"); | "output format not found (available: json)"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_mempool_info(Config &config, HTTPRequest *req, | static bool rest_mempool_info(Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
Show All 9 Lines | switch (rf) { | ||||
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: json)"); | "output format not found (available: json)"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_mempool_contents(Config &config, HTTPRequest *req, | static bool rest_mempool_contents(Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
Show All 9 Lines | switch (rf) { | ||||
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: json)"); | "output format not found (available: json)"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_tx(Config &config, HTTPRequest *req, | static bool rest_tx(Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
"output format not found (available: " + | "output format not found (available: " + | ||||
AvailableDataFormatsString() + ")"); | AvailableDataFormatsString() + ")"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static bool rest_getutxos(Config &config, HTTPRequest *req, | static bool rest_getutxos(Config &config, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
return true; | return true; | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
"output format not found (available: " + | "output format not found (available: " + | ||||
AvailableDataFormatsString() + ")"); | AvailableDataFormatsString() + ")"); | ||||
} | } | ||||
} | } | ||||
// not reached | |||||
// continue to process further HTTP reqs on this cxn | |||||
return true; | |||||
} | } | ||||
static const struct { | static const struct { | ||||
const char *prefix; | const char *prefix; | ||||
bool (*handler)(Config &config, HTTPRequest *req, | bool (*handler)(Config &config, HTTPRequest *req, | ||||
const std::string &strReq); | const std::string &strReq); | ||||
} uri_prefixes[] = { | } uri_prefixes[] = { | ||||
{"/rest/tx/", rest_tx}, | {"/rest/tx/", rest_tx}, | ||||
Show All 25 Lines |