Spin is a framework and runtime for running WebAssembly applications as event-driven microservices. It provides an off-the-shelf host, SDKs, templates, and a developer toolchain so applications can focus on business logic instead of custom host construction. section 6.0 section 6.5
A Spin application connects events to WebAssembly components through an application manifest:
- Choose a template with spin new, including HTTP and Redis handlers for Rust, Go, JavaScript, TypeScript, Python, .NET, and other languages. section 6.5.1
- Define the application, components, routes, source files, build command, and outbound-host permissions in spin.toml. section 6.5.1
- Map triggers such as HTTP requests or Redis messages to the components that handle them. section 6.5.1
- Build with spin build and run locally with spin up; Spin serves the configured route and logs component output. section 6.5.1
Rust HTTP hello world
Selecting the http-rust template creates hello-world-spin with Cargo.toml, spin.toml, and src. The generated handler uses the Spin HTTP SDK, prints the request URL, and returns a 200 response containing “Hello World!”. After spin build and spin up, curl http://127.0.0.1:3000 verifies the route. Spin creates request-handling instances by default; oha can benchmark concurrent requests. section 6.5.1 section 6.5.2
spin new
Use the Spin project-generation command to select an HTTP, Redis, static-file, or language-specific starter template. section 6.5.1
