-
Notifications
You must be signed in to change notification settings - Fork 578
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
Improve system api to perform HTTP requests #2631
base: main
Are you sure you want to change the base?
Conversation
0f528cb
to
2cc7ab5
Compare
2cc7ab5
to
550315e
Compare
Make it easier to find feature definitions.
Prepare to allow applications to specify the HTTP method to use.
Prepare to support other HTTP methods.
Allow specifying which HTTP method should be used for the request.
Allow specifying multiple headers for the request.
Use a broader name since now the HTTP method can be specified.
They don't seem to be used.
Make it simpler to tweak how it is serialized and formatted for debug output.
Represent useful information from an HTTP response.
Instead of just the response body.
Collect all the parameters for `http_request` into a single type.
Simplify the API a bit, and make it simpler to change the types in the future if needed.
Allow creating some simple common HTTP requests.
Make it easy to add headers to `http::Request`s.
The API is already available in the WIT interface, so it makes sense to expose it in a more discoverable way.
Allow services to write unit tests using the new API.
Provide access to the `http::Request` and `http::Response` types needed to use the APIs.
Allow it to be enabled for testing.
Make it simple to create a new `Response` with just a status code and no headers or body.
Make it easy to build simple success responses.
Make it easy to build simple unauthorized error responses.
Make it easy to add headers to `http::Response`s.
550315e
to
26a5299
Compare
/// A POST request. | ||
Post, | ||
|
||
/// A PUT request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we support all these methods?
Where do we expect the contract (whose state and code are both public) to get this information? 🤔 |
This use case specifically was needed in the service for the airdrop demo. But yeah, for contracts other custom headers might be more relevant. |
Motivation
Linera applications can perform HTTP requests to external services, but the available
http_post
API was very limited, and prevented applications from configuring the request. This is often needed in order to add custom headers, for example for authentication.Proposal
Replace the
http_post
API with a broaderhttp_request
API, which allows sending more configurablehttp::Request
s, and returns a more detailedhttp::Response
.Test Plan
TODO
Release Plan
devnet
and release a newSDK soon.
linera-sdk
API.Links