setup Spin binary to be used
% spin templates install --git https://github.com/fermyon/spin
% mkdir sample-http-rust ; cd sample-http-rust
% spin new http-rust
Project description: a sample Spin HTTP Component in Rust
Project name: sample-http-rust
HTTP base: /
HTTP path: /demo
% tree .
[drwxr-xr-x abhishekkr 4.0K] .
├── [-rw-r--r-- abhishekkr 682] "Cargo.toml"
├── [-rw-r--r-- abhishekkr 414] "spin.toml"
└── [drwxr-xr-x abhishekkr 4.0K] "src"/
└── [-rw-r--r-- abhishekkr 369] "lib.rs"
-
spin.toml defines
[[component]]with/demoroute trigger & source forsample_http_rust.wasm -
src/lib.rs has
#http_componentmacro annotated overfn sample_http_rust -
spin buildto compile source;spin buil --upto compile and start the app;spin upto just run
http://127.0.0.1:3000/demoas default servefor detailed logs use
export RUST_LOG=spin=trace
-
can add more components via
spin.toml -
can have different component under different projects; with an external
spin.toml; as under sample-app