-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for
wasi:http/[email protected]
(#2166)
* add support for `wasi:http/[email protected]` This builds upon Alex's excellent work in #2108, adding the ability to run guests which target the `0.2.0-rc-2023-11-10` version of `wasi-http`. I've added a test which uses `wit-bindgen` and `wit-component` directly to ensure it uses the correct snapshot for everything `wasi-http`, `wasi-cli`, etc. Note that we're not yet updating any SDKs to use the new snapshot, since we still want people to be able to use the new SDK to target Spin 2.0. Signed-off-by: Joel Dice <[email protected]> * use different names for `wasi-http-rust-rc-2023-11-10` module and component Previously, I tried to be clever and overwrite the module with the component, but that led to a filesystem-level race condition and was just generally fragile. Signed-off-by: Joel Dice <[email protected]> --------- Signed-off-by: Joel Dice <[email protected]>
- Loading branch information
Showing
46 changed files
with
3,469 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 |
---|---|---|
|
@@ -51,7 +51,10 @@ impl HttpExecutor for HttpHandlerExecutor { | |
.await | ||
.map_err(contextualise_err)? | ||
} | ||
None => bail!("Expected component to either export `{}` or `fermyon:spin/inbound-http` but it exported neither", WASI_HTTP_EXPORT) | ||
None => bail!( | ||
"Expected component to either export `{WASI_HTTP_EXPORT_2023_10_18}`, \ | ||
`{WASI_HTTP_EXPORT_2023_11_10}`, or `fermyon:spin/inbound-http` but it exported neither" | ||
) | ||
}; | ||
|
||
tracing::info!( | ||
|
@@ -302,12 +305,15 @@ enum HandlerType { | |
Wasi, | ||
} | ||
|
||
const WASI_HTTP_EXPORT: &str = "wasi:http/[email protected]"; | ||
const WASI_HTTP_EXPORT_2023_10_18: &str = "wasi:http/[email protected]"; | ||
const WASI_HTTP_EXPORT_2023_11_10: &str = "wasi:http/[email protected]"; | ||
|
||
impl HandlerType { | ||
/// Determine the handler type from the exports | ||
fn from_exports(mut exports: wasmtime::component::Exports<'_>) -> Option<HandlerType> { | ||
if exports.instance(WASI_HTTP_EXPORT).is_some() { | ||
if exports.instance(WASI_HTTP_EXPORT_2023_10_18).is_some() | ||
|| exports.instance(WASI_HTTP_EXPORT_2023_11_10).is_some() | ||
{ | ||
return Some(HandlerType::Wasi); | ||
} | ||
if exports.instance("fermyon:spin/inbound-http").is_some() { | ||
|
2 changes: 2 additions & 0 deletions
2
tests/http/wasi-http-rust-0.2.0-rc-2023-11-10/.cargo/config.toml
This file contains 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,2 @@ | ||
[build] | ||
target = "wasm32-wasi" |
Oops, something went wrong.