Skip to content

Conversation

stickies-v
Copy link
Contributor

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?).

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 31, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept NACK luke-jr

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25760 (rest: clean-up for mempool endpoints by brunoerg)
  • #25722 (refactor: Use util::Result class for wallet loading by ryanofsky)
  • #25721 (refactor: Replace BResult with util::Result by ryanofsky)
  • #25665 (refactor: Add util::Result class and use it in LoadChainstate by ryanofsky)
  • #23599 ([WIP] DRAFT NOMERGE Tidy up RPCTxSerializationFlags by MarcoFalke)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 5, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

In future commits, we'll need to directly convert a format string
into RESTResponseFormat without all the other logic from ParseDataFormat
Equivalent of -deprecatedrpc for the REST API. Allows the user to
keep the specified deprecated functionality unchanged
Instead of specifying the response format as an e.g. ".json" path
parameter, the format string is now expected to be in the query
string "?format=json". This allows for a more standardized URI
format, and removes the dependency on too tightly coupled code like
ParseDataFormat().

Can be overridden with -deprecatedrest=format, which enables automatic
parsing of the URI to move format strings from the path to the query.
No longer necessary since response format is a query parameter
@stickies-v stickies-v force-pushed the rest/query-params-0-prep branch from 20fb03f to 901b132 Compare August 5, 2022 14:06
@luke-jr
Copy link
Member

luke-jr commented Aug 9, 2022

Concept NACK. Not only does it break the API, the current interface is what is expected for format specification everywhere.

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

1 similar comment
@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko
Copy link
Member

maflcko commented Mar 13, 2023

@stickies-v Looks like this was opened as draft a year ago with no further activity from you. Can this be closed?

@stickies-v
Copy link
Contributor Author

Closing as per #25752 (comment)

@stickies-v stickies-v closed this Mar 13, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants