MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ParseDataFormat

Function ParseDataFormat

src/rest.cpp:130–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130RESTResponseFormat ParseDataFormat(std::string& param, const std::string& strReq)
131{
132 // Remove query string (if any, separated with '?') as it should not interfere with
133 // parsing param and data format
134 param = strReq.substr(0, strReq.rfind('?'));
135 const std::string::size_type pos_format{param.rfind('.')};
136
137 // No format string is found
138 if (pos_format == std::string::npos) {
139 return RESTResponseFormat::UNDEF;
140 }
141
142 // Match format string to available formats
143 const std::string suffix(param, pos_format + 1);
144 for (const auto& rf_name : rf_names) {
145 if (suffix == rf_name.name) {
146 param.erase(pos_format);
147 return rf_name.rf;
148 }
149 }
150
151 // If no suffix is found, return RESTResponseFormat::UNDEF and original string without query string
152 return RESTResponseFormat::UNDEF;
153}
154
155static std::string AvailableDataFormatsString()
156{

Callers 12

rest_headersFunction · 0.85
rest_spent_txoutsFunction · 0.85
rest_blockFunction · 0.85
rest_filter_headerFunction · 0.85
rest_block_filterFunction · 0.85
rest_chaininfoFunction · 0.85
rest_deploymentinfoFunction · 0.85
rest_mempoolFunction · 0.85
rest_txFunction · 0.85
rest_getutxosFunction · 0.85
rest_blockhash_by_heightFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 1

eraseMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68