This repository was archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add basic scaffolding for wasi http #85
Merged
eduardomourar
merged 20 commits into
bytecodealliance:main
from
eduardomourar:feat/wasi-http-experimental
Mar 17, 2023
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c3af8fd
feat: add wasi http experimental
eduardomourar e707e13
feat: add bindings crate
eduardomourar c5da583
feat: return monadic type for http request
eduardomourar 6b7faa4
chore: rename main http function to send
eduardomourar 8c6043e
chore: update wit-bindgen in bindings crate
eduardomourar 9dc2233
chore: change http method to enum
eduardomourar 72116e3
chore: remove http status error
eduardomourar b2382e6
Merge branch 'main' into feat/wasi-http-experimental
eduardomourar bae5545
feat: use new wasi-http wit definition
eduardomourar 922f4a7
Merge remote-tracking branch 'origin/main' into feat/wasi-http-experi…
eduardomourar dd74ffc
Merge remote-tracking branch 'origin/main' into feat/wasi-http-experi…
eduardomourar 1e38e23
chore: add basic scaffolding for wasi http
eduardomourar e8cbfcd
Merge remote-tracking branch 'origin/main' into feat/wasi-http-experi…
eduardomourar 0bb1f0e
chore: revert rename for http types
eduardomourar 533894a
chore: changes based on review feedback
eduardomourar 0933bc4
chore: add modules to verify
eduardomourar 09b0c8d
chore: include features wasi bindings
eduardomourar 7f41229
chore: update lock file
eduardomourar bce17d1
chore: fix formatting
eduardomourar cdac89d
chore: fix casing for http imported names
eduardomourar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| use crate::{ | ||
| wasi, | ||
| wasi::types::{FutureIncomingResponse as Response, OutgoingRequest as Request, RequestOptions}, | ||
| WasiCtx, | ||
| }; | ||
|
|
||
| #[async_trait::async_trait] | ||
| impl wasi::default_outgoing_http::Host for WasiCtx { | ||
| async fn handle( | ||
| &mut self, | ||
| _req: Request, | ||
| _options: Option<RequestOptions>, | ||
| ) -> wasmtime::Result<Response> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| use crate::{ | ||
| wasi, | ||
| wasi::types::{IncomingRequest as Request, ResponseOutparam as Response}, | ||
| WasiCtx, | ||
| }; | ||
|
|
||
| #[async_trait::async_trait] | ||
| impl wasi::http::Host for WasiCtx { | ||
| async fn handle(&mut self, _req: Request, _resp: Response) -> anyhow::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| use crate::{ | ||
| wasi, | ||
| wasi::poll::Pollable, | ||
| wasi::types::{ | ||
| Error, Fields, FutureIncomingResponse, Headers, IncomingRequest, IncomingResponse, | ||
| IncomingStream, Method, OutgoingRequest, OutgoingResponse, OutgoingStream, | ||
| ResponseOutparam, Scheme, StatusCode, Trailers, | ||
| }, | ||
| WasiCtx, | ||
| }; | ||
|
|
||
| #[async_trait::async_trait] | ||
| impl wasi::types::Host for WasiCtx { | ||
| async fn drop_fields(&mut self, _fields: Fields) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn new_fields(&mut self, _entries: Vec<(String, String)>) -> wasmtime::Result<Fields> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_get( | ||
| &mut self, | ||
| _fields: Fields, | ||
| _name: String, | ||
| ) -> wasmtime::Result<Vec<String>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_set( | ||
| &mut self, | ||
| _fields: Fields, | ||
| _name: String, | ||
| _value: Vec<String>, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_delete(&mut self, _fields: Fields, _name: String) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_append( | ||
| &mut self, | ||
| _fields: Fields, | ||
| _name: String, | ||
| _value: String, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_entries(&mut self, _fields: Fields) -> wasmtime::Result<Vec<(String, String)>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn fields_clone(&mut self, _fields: Fields) -> wasmtime::Result<Fields> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn finish_incoming_stream( | ||
| &mut self, | ||
| _s: IncomingStream, | ||
| ) -> wasmtime::Result<Option<Trailers>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn finish_outgoing_stream( | ||
| &mut self, | ||
| _s: OutgoingStream, | ||
| _trailers: Option<Trailers>, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_incoming_request(&mut self, _request: IncomingRequest) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_outgoing_request(&mut self, _request: OutgoingRequest) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_method( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<Method> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_path( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<String> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_scheme( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<Option<Scheme>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_authority( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<String> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_headers( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<Headers> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_consume( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<Result<IncomingStream, ()>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_request_query( | ||
| &mut self, | ||
| _request: IncomingRequest, | ||
| ) -> wasmtime::Result<String> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn new_outgoing_request( | ||
| &mut self, | ||
| _method: Method, | ||
| _path: String, | ||
| _query: String, | ||
| _scheme: Option<Scheme>, | ||
| _authority: String, | ||
| _headers: Headers, | ||
| ) -> wasmtime::Result<OutgoingRequest> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn outgoing_request_write( | ||
| &mut self, | ||
| _request: OutgoingRequest, | ||
| ) -> wasmtime::Result<Result<OutgoingStream, ()>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_response_outparam( | ||
| &mut self, | ||
| _response: ResponseOutparam, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn set_response_outparam( | ||
| &mut self, | ||
| _response: Result<OutgoingResponse, Error>, | ||
| ) -> wasmtime::Result<Result<(), ()>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_incoming_response( | ||
| &mut self, | ||
| _response: IncomingResponse, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_outgoing_response( | ||
| &mut self, | ||
| _response: OutgoingResponse, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_response_status( | ||
| &mut self, | ||
| _response: IncomingResponse, | ||
| ) -> wasmtime::Result<StatusCode> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_response_headers( | ||
| &mut self, | ||
| _response: IncomingResponse, | ||
| ) -> wasmtime::Result<Headers> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn incoming_response_consume( | ||
| &mut self, | ||
| _response: IncomingResponse, | ||
| ) -> wasmtime::Result<Result<IncomingStream, ()>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn new_outgoing_response( | ||
| &mut self, | ||
| _status_code: StatusCode, | ||
| _headers: Headers, | ||
| ) -> wasmtime::Result<OutgoingResponse> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn outgoing_response_write( | ||
| &mut self, | ||
| _response: OutgoingResponse, | ||
| ) -> wasmtime::Result<Result<OutgoingStream, ()>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn drop_future_incoming_response( | ||
| &mut self, | ||
| _f: FutureIncomingResponse, | ||
| ) -> wasmtime::Result<()> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn future_incoming_response_get( | ||
| &mut self, | ||
| _f: FutureIncomingResponse, | ||
| ) -> wasmtime::Result<Option<Result<IncomingResponse, Error>>> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| async fn listen_to_future_incoming_response( | ||
| &mut self, | ||
| _f: FutureIncomingResponse, | ||
| ) -> wasmtime::Result<Pollable> { | ||
| anyhow::bail!("not implemented") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // The `wasi:http/incoming-handler` interface is meant to be exported by | ||
| // components and called by the host in response to a new incoming HTTP | ||
| // response. | ||
| // | ||
| // NOTE: in Preview3, this interface will be merged with | ||
| // `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface | ||
| // that takes a `request` parameter and returns a `response` result. | ||
| // | ||
| default interface incoming-handler { | ||
| use pkg.types.{incoming-request, response-outparam} | ||
|
|
||
| // The `handle` function takes an outparam instead of returning its response | ||
| // so that the component may stream its response while streaming any other | ||
| // request or response bodies. The callee MUST write a response to the | ||
| // `response-out` and then finish the response before returning. The `handle` | ||
| // function is allowed to continue execution after finishing the response's | ||
| // output stream. While this post-response execution is taken off the | ||
| // critical path, since there is no return value, there is no way to report | ||
| // its success or failure. | ||
| handle: func( | ||
| request: incoming-request, | ||
| response-out: response-outparam | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // The `wasi:http/outgoing-handler` interface is meant to be imported by | ||
| // components and implemented by the host. | ||
| // | ||
| // NOTE: in Preview3, this interface will be merged with | ||
| // `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface | ||
| // that takes a `request` parameter and returns a `response` result. | ||
| // | ||
| default interface outgoing-handler { | ||
| use pkg.types.{outgoing-request, request-options, future-incoming-response} | ||
|
|
||
| // The parameter and result types of the `handle` function allow the caller | ||
| // to concurrently stream the bodies of the outgoing request and the incoming | ||
| // response. | ||
| handle: func( | ||
| request: outgoing-request, | ||
| options: option<request-options> | ||
| ) -> future-incoming-response | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.