Draft, for reference only to support #25752 for discussion on concept and approach. Code and tests should be fully functional, but still to be considered rough.
Brief summary
All REST API endpoints require the user to specify the response format by including a format string at the end of the path (e.g. /rest/chaininfo.json
). This PR removes the path-like parameter and updates all endpoints to use a ?format
query parameter, which defaults to json
if unspecified.
Previous behaviour can be preserved through -deprecatedrest=format
Benefits:
- only use (standard) path and query parameters, no custom dot-separated parameter
- a default
json
response format seems reasonable, and was trivial to implement with a query parameter - simplify code since we don’t need bespoke logic to parse the format, e.g. remove
ParseDataFormat()
function which had too many responsibilities - Introduce
-deprecatedrest
startup option, similar to-deprecatedrpc
. With this option, we keep API changes backwards compatible for as long as the-deprecatedrest
option is available (usually 1 version?).