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

feat: add the HTTP bindings to perform HTTP requests from workers #168

Merged
merged 5 commits into from
Jul 5, 2023

Conversation

Angelmmiguel
Copy link
Contributor

Define the new bindings to perform HTTP request from inside the workers. The outcome of this PR is that workers can import a send-http-request function to send HTTP requests through the host. This features opens many new possibilities and it's a pretty standard API in any worker-based platform.

It refs #165

Interface definition

For now, we are not using the latest WIT syntax (including package). The wit-bindgen version that supports it only works with components. Wasm Workers Server doesn't support components yet, but we will switch to them in the future, while keeping compatibility with core components.

For this reason, we're pinning the wit-bindgen dependency to the v2.0 version on the client side (I'll send a separate PR with these changes).

On the host side, we're using the wit-bindgen-backport fork from the Fermyon team. This fork is compatible with the latest Wasmtime version and the wit-bindgen v2 version.

Changes

  • Add the .wit files that defines the bindings and types
  • Add a new folder structure in the worker crate for future bindings
  • Implement the bindings on Wasm Workers Server using reqwest

@Angelmmiguel Angelmmiguel added the 🚀 enhancement New feature or request label Jul 4, 2023
@Angelmmiguel Angelmmiguel added this to the v1.4.0 milestone Jul 4, 2023
@Angelmmiguel Angelmmiguel requested a review from a team July 4, 2023 11:29
@Angelmmiguel Angelmmiguel self-assigned this Jul 4, 2023
Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @Angelmmiguel. Some comments :)

Cargo.toml Outdated Show resolved Hide resolved
crates/worker/src/bindings/http.rs Outdated Show resolved Hide resolved
@Angelmmiguel Angelmmiguel merged commit 103f1cf into main Jul 5, 2023
@Angelmmiguel Angelmmiguel deleted the 165-add-http-bindings branch July 6, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants