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

feature: Go net/http -> wasi:http Proxy #34

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

lxfontes
Copy link
Member

@lxfontes lxfontes commented Sep 10, 2024

Helpers to proxy HTTP Requests from Go's standard library over to WRPC wasi:http.

Proxying uses a custom http.RoundTripper implementation that forwards requests to the component. In this example we forward to a single target ( http-http_component ).

transport := wrpchttp.NewIncomingRoundTripper(wasmcloudprovider, wrpchttp.WithSingleTarget("http-http_component"))

wasiIncomingClient := &http.Client{
  Transport: transport,
}

wasiIncomingClient.Get("http://localhost:8080/proxy")

Tests

wrpchttp ❯ go test -cover
PASS
coverage: 83.1% of statements
ok  	go.wasmcloud.dev/provider/wrpchttp	0.250s

The provided example is a HTTP <> WASI Proxy analogous to https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-server

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
@lxfontes lxfontes marked this pull request as ready for review September 13, 2024 20:50
@lxfontes lxfontes requested a review from a team as a code owner September 13, 2024 20:50
Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
@lxfontes lxfontes merged commit fd7d2c9 into wasmCloud:main Sep 13, 2024
3 checks passed
@lxfontes lxfontes deleted the lxfontes/http-server branch September 13, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants