Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GET endpoints that use POST method to use new HTTP QUERY #219

Closed
JoeCap08055 opened this issue Jun 26, 2024 · 1 comment
Closed
Labels
Blocked enhancement New feature or request

Comments

@JoeCap08055
Copy link
Contributor

(NOTE: filing this issue here because it applies to multiple Gateway services, and in anticipation that we will be migrating the services' code to this repo as a monorepo, and that any modifications to the Gateway APIs resulting from this issue will not take place until after such a monorepo migration. We'll also probably want to wait until Node.js 22.x is promoted to LTS)

Description

As a developer, I expect REST methods to clearly embody the underlying HTTP request. Previously, in order to support a complex query (ie, where the resource query parameters are either too long for a standard URI, or have problems with encoding/escaping), there have been two options:

  1. Use a GET request with a body. Although this does not violate the HTTP standard, its use is controversial and may not be supported by all server implementations.
  2. Use a POST request to communicate the query parameters in the body of the message, but the endpoint is actually idempotent as relates to the data itself, and behaves more or less like a GET. This is a common approach, but disliked as a "necessary evil"

Potential Solution

Use the new HTTP QUERY operator, which is, for all intents and purposes, "GET with a body". The QUERY operator is now supported by Node.js 22.2.0.

References

See here for an explanation and examples. For some of our more common Gateway use cases, the "query with indirect response" might be a good approach. In this model, the QUERY endpoint responds with an HTTP 303 "See Other" response containing a URL which maps to a GET request for the query results. This is useful for many of our blockchain operations for which we cannot provide results synchronously (for instance, a search request that requires scanning the chain for results)

@JoeCap08055 JoeCap08055 added the enhancement New feature or request label Jun 26, 2024
@wilwade
Copy link
Contributor

wilwade commented Jul 30, 2024

Future

@wilwade wilwade closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants