Skip to content

Commit abc1d54

Browse files
Add HTTP Rust template for wasip3-unstable (#3345)
Signed-off-by: Brian Hardock <[email protected]>
1 parent 220f314 commit abc1d54

File tree

6 files changed

+60
-1
lines changed

6 files changed

+60
-1
lines changed

crates/templates/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ mod tests {
566566
}
567567
}
568568

569-
const TPLS_IN_THIS: usize = 11;
569+
const TPLS_IN_THIS: usize = 12;
570570

571571
#[tokio::test]
572572
async fn can_install_into_new_directory() {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+
.spin/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "{{project-name | kebab_case}}"
3+
authors = ["{{authors}}"]
4+
description = "{{project-description}}"
5+
version = "0.1.0"
6+
rust-version = "1.90"
7+
edition = "2021"
8+
9+
[lib]
10+
crate-type = ["cdylib"]
11+
12+
[dependencies]
13+
anyhow = "1"
14+
spin-sdk = { version = "5.1.0", features = ["wasip3-unstable"] }
15+
16+
[workspace]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#:schema https://schemas.spinframework.dev/spin/manifest-v2/latest.json
2+
3+
spin_manifest_version = 2
4+
5+
[application]
6+
name = "{{project-name | kebab_case}}"
7+
version = "0.1.0"
8+
authors = ["{{authors}}"]
9+
description = "{{project-description}}"
10+
11+
[[trigger.http]]
12+
route = "{{http-path}}"
13+
component = "{{project-name | kebab_case}}"
14+
executor = { type = "wasip3-unstable" }
15+
16+
[component.{{project-name | kebab_case}}]
17+
source = "target/wasm32-wasip2/release/{{project-name | snake_case}}.wasm"
18+
allowed_outbound_hosts = []
19+
[component.{{project-name | kebab_case}}.build]
20+
command = "cargo build --target wasm32-wasip2 --release"
21+
watch = ["src/**/*.rs", "Cargo.toml"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use spin_sdk::http_wasip3::{http_service, IntoResponse, Request, Response};
2+
3+
/// A simple Spin HTTP component.
4+
#[http_service]
5+
async fn handle_{{project-name | snake_case}}(_req: Request) -> impl IntoResponse {
6+
Response::new("Hello, world!".to_string())
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
manifest_version = "1"
2+
id = "http-rust-wasip3-unstable"
3+
description = "WASIp3 HTTP request handler using Rust (0.3.0-rc-2025-09-16)"
4+
tags = ["http", "rust"]
5+
6+
[add_component]
7+
skip_files = ["spin.toml"]
8+
[add_component.snippets]
9+
component = "component.txt"
10+
11+
[parameters]
12+
project-description = { type = "string", prompt = "Description", default = "" }
13+
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }

0 commit comments

Comments
 (0)