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

Remove wasi-experimental-http support #699

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ lint:
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --all -- --check

.PHONY: check-rust-examples
check-rust-examples:
for manifest_path in examples/*/Cargo.toml; do \
cargo clippy --manifest-path "$${manifest_path}" -- -D warnings || exit 1 ; \
done

.PHONY: test-unit
test-unit:
RUST_LOG=$(LOG_LEVEL) cargo test --all --no-fail-fast -- --skip integration_tests --nocapture --include-ignored
Expand Down
1 change: 0 additions & 1 deletion crates/outbound-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ tokio = { version = "1.4.0", features = [ "full" ] }
tracing = { version = "0.1", features = [ "log" ] }
tracing-futures = "0.2"
url = "2.2.1"
wasi-experimental-http-wasmtime = "0.10.0"
wit-bindgen-wasmtime = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "dde4694aaa6acf9370206527a798ac4ba6a8c5b8" }
20 changes: 6 additions & 14 deletions crates/outbound-http/src/host_component.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
use anyhow::Result;
use wit_bindgen_wasmtime::wasmtime::Linker;

use spin_engine::{
host_component::{HostComponent, HostComponentsStateHandle},
RuntimeContext,
};
use spin_manifest::CoreComponent;
use wasi_experimental_http_wasmtime::{HttpCtx as ExperimentalHttpCtx, HttpState};
use wit_bindgen_wasmtime::wasmtime::Linker;

use crate::OutboundHttp;

pub struct OutboundHttpComponent;

impl HostComponent for OutboundHttpComponent {
type State = (OutboundHttp, ExperimentalHttpCtx);
type State = OutboundHttp;

fn add_to_linker<T>(
linker: &mut Linker<RuntimeContext<T>>,
data_handle: HostComponentsStateHandle<Self::State>,
) -> Result<()> {
crate::add_to_linker(linker, move |ctx| &mut data_handle.get_mut(ctx).0)?;
HttpState::new()
.expect("HttpState::new failed")
.add_to_linker(linker, move |ctx| data_handle.get(ctx).1.clone())?;
crate::add_to_linker(linker, move |ctx| data_handle.get_mut(ctx))?;
Ok(())
}

fn build_state(&self, component: &CoreComponent) -> Result<Self::State> {
let outbound_http = OutboundHttp {
allowed_hosts: Some(component.wasm.allowed_http_hosts.clone()),
};
let experimental_http = ExperimentalHttpCtx {
Ok(OutboundHttp {
allowed_hosts: Some(component.wasm.allowed_http_hosts.clone()),
max_concurrent_requests: None,
};
Ok((outbound_http, experimental_http))
})
}
}
3 changes: 1 addition & 2 deletions docs/content/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ Each `component` object has the following fields:
WebAssembly module. For example
`{ source = "content/", destination = "/"}`.
- `allowed_http_hosts` (OPTIONAL): List of HTTP hosts the component is allowed
to make HTTP requests to (using the
[WASI experimental HTTP library](https://github.com/deislabs/wasi-experimental-http))
to make HTTP requests to
- `trigger` (REQUIRED): Trigger configuration for the component. Triggers are
the components that generate events that cause the execution of components.
The trigger configuration for a component must be compatible with the top-level
Expand Down
3 changes: 1 addition & 2 deletions docs/content/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ record response {
```

> The same HTTP types are also used to model the API for sending outbound
> HTTP requests, and you can see its implementation in
> [the WASI toolkit repository](https://github.com/fermyon/wasi-experimental-toolkit).
> HTTP requests.

Then, we define the entry point for a Spin HTTP component:

Expand Down
104 changes: 17 additions & 87 deletions examples/config-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading