diff --git a/crates/templates/src/manager.rs b/crates/templates/src/manager.rs index 5accd15cce..53b82b0476 100644 --- a/crates/templates/src/manager.rs +++ b/crates/templates/src/manager.rs @@ -566,7 +566,7 @@ mod tests { } } - const TPLS_IN_THIS: usize = 11; + const TPLS_IN_THIS: usize = 12; #[tokio::test] async fn can_install_into_new_directory() { diff --git a/templates/http-rust-wasip3-unstable/content/.gitignore b/templates/http-rust-wasip3-unstable/content/.gitignore new file mode 100644 index 0000000000..386474fa59 --- /dev/null +++ b/templates/http-rust-wasip3-unstable/content/.gitignore @@ -0,0 +1,2 @@ +target/ +.spin/ diff --git a/templates/http-rust-wasip3-unstable/content/Cargo.toml.tmpl b/templates/http-rust-wasip3-unstable/content/Cargo.toml.tmpl new file mode 100644 index 0000000000..025a75265e --- /dev/null +++ b/templates/http-rust-wasip3-unstable/content/Cargo.toml.tmpl @@ -0,0 +1,16 @@ +[package] +name = "{{project-name | kebab_case}}" +authors = ["{{authors}}"] +description = "{{project-description}}" +version = "0.1.0" +rust-version = "1.90" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +anyhow = "1" +spin-sdk = { version = "5.1.0", features = ["wasip3-unstable"] } + +[workspace] diff --git a/templates/http-rust-wasip3-unstable/content/spin.toml b/templates/http-rust-wasip3-unstable/content/spin.toml new file mode 100644 index 0000000000..0df5fb9944 --- /dev/null +++ b/templates/http-rust-wasip3-unstable/content/spin.toml @@ -0,0 +1,21 @@ +#:schema https://schemas.spinframework.dev/spin/manifest-v2/latest.json + +spin_manifest_version = 2 + +[application] +name = "{{project-name | kebab_case}}" +version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" + +[[trigger.http]] +route = "{{http-path}}" +component = "{{project-name | kebab_case}}" +executor = { type = "wasip3-unstable" } + +[component.{{project-name | kebab_case}}] +source = "target/wasm32-wasip2/release/{{project-name | snake_case}}.wasm" +allowed_outbound_hosts = [] +[component.{{project-name | kebab_case}}.build] +command = "cargo build --target wasm32-wasip2 --release" +watch = ["src/**/*.rs", "Cargo.toml"] diff --git a/templates/http-rust-wasip3-unstable/content/src/lib.rs b/templates/http-rust-wasip3-unstable/content/src/lib.rs new file mode 100644 index 0000000000..a19ec17eff --- /dev/null +++ b/templates/http-rust-wasip3-unstable/content/src/lib.rs @@ -0,0 +1,7 @@ +use spin_sdk::http_wasip3::{http_service, IntoResponse, Request, Response}; + +/// A simple Spin HTTP component. +#[http_service] +async fn handle_{{project-name | snake_case}}(_req: Request) -> impl IntoResponse { + Response::new("Hello, world!".to_string()) +} diff --git a/templates/http-rust-wasip3-unstable/metadata/spin-template.toml b/templates/http-rust-wasip3-unstable/metadata/spin-template.toml new file mode 100644 index 0000000000..4d1572a792 --- /dev/null +++ b/templates/http-rust-wasip3-unstable/metadata/spin-template.toml @@ -0,0 +1,13 @@ +manifest_version = "1" +id = "http-rust-wasip3-unstable" +description = "WASIp3 HTTP request handler using Rust (0.3.0-rc-2025-09-16)" +tags = ["http", "rust"] + +[add_component] +skip_files = ["spin.toml"] +[add_component.snippets] +component = "component.txt" + +[parameters] +project-description = { type = "string", prompt = "Description", default = "" } +http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } \ No newline at end of file