Skip to content

Latest commit

 

History

History
 
 

rust

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

spin-fileserver-example (Rust)

This is an example of using component composition to compose an example app with spin-fileserver, a reusable component for serving static files.

Prerequisites

Once you have Rust installed, the following should give you everything else:

rustup target add wasm32-wasi
cargo install cargo-component
cargo install --locked --git https://github.com/dicej/wasm-tools \
    --branch wasm-compose-resource-imports wasm-tools

Building and Running

To build and run the example, run:

spin build -u

Then, in another terminal, you can test it using curl:

curl -i http://127.0.0.1:3000/hello

The above should return a response body Hello, world!, served up by the example app itself. All other URIs are handled by spin-fileserver, e.g.:

curl -i http://127.0.0.1:3000/foo.txt
curl -i http://127.0.0.1:3000/nonexistent.txt