Skip to content
New issue

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

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

Already on GitHub? # to your account

Add default HTTP client compatible with Spin SDK #1369

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

radu-matei
Copy link
Member

This commit adds an init function to the SDK's HTTP package that
overrides the default HTTP client to use the internals for sending an
outbound HTTP request compatible with Spin.

This has two implications:

  • calls to http.Get or http.Post (i.e using the standard way of
    making HTTP requests in Go) should now work by default in Spin
    applications
  • future updates to WASI and Go networking should mean fewer changes to
    applications that take this approach.

Note that this does not prevent passing a custom HTTP client to
libraries that support this.

Signed-off-by: Radu Matei radu.matei@fermyon.com

This commit adds an `init` function to the SDK's HTTP package that
overrides the default HTTP client to use the internals for sending an
outbound HTTP request compatible with Spin.

This has two implications:

* calls to `http.Get` or `http.Post` (i.e using the standard way of
  making HTTP requests in Go) should now work by default in Spin
  applications
* future updates to WASI and Go networking should mean fewer changes to
  applications that take this approach.

Note that this does not prevent passing a custom HTTP client to
libraries that support this.

Signed-off-by: Radu Matei <radu.matei@fermyon.com>
Copy link
Member

@michelleN michelleN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paired with @radu-matei to manually test this. We did a simple http get to ensure that using the sdk still works. The real exciting part of this change is that you can now import and use libraries that make standard http requests under the hood so yay 🎉 ! We discussed testing and decided to hold off since this is more in an experimental state for using with deps. We also discussed how this impacts non http spin apps that use libraries that make http calls. @radu-matei has some ideas around that (potentially adding the same init func to the redis package with an underscore import _ github.com/fermyon/spin/sdk/go/http and will submit a follow up PR to address that.

@michelleN michelleN merged commit d6be138 into fermyon:main Apr 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants