Deploy a Rust API
This tutorial builds a JSON API in Rust as a WebAssembly component and deploys
it to Hyjal on the Rust lane. You end with a public HTTPS endpoint that returns
JSON, proven with curl.
Time: about ten minutes. You need the hyjal CLI, a
logged-in session, and a Rust toolchain with the
wasm32-wasip2 target and cargo component.
1. Create the component
Scaffold a new component crate:
Implement the wasi:http incoming handler. The component returns a JSON body
for every request.
2. Build locally
Confirm the component compiles to a wasip2 artifact:
3. Write the manifest
Add a hyjal.toml declaring the api Resource on the
Rust lane. Make it public so you can reach it directly.
The Rust lane runs cargo component build for you at deploy; you do not need to
commit the built artifact.
4. Deploy
5. Verify with curl
Call the endpoint:
Inspect the headers to confirm the status and content type:
Each call ran on a fresh Afterburner instance, metered and discarded. No state carries between requests.
6. Watch the requests
What you built
- A Rust
wasi:httpcomponent that returns JSON. - A public endpoint at
https://api--acme.hyjal.cloudon the Rust lane. - A working
curlrequest served instance-per-request.
Next steps
- Front the API with a web Resource: Full-stack tutorial
- Connect a database: Connect Postgres
- Read the language reference: Rust