Expand description
§cufflink-fn
Write custom Cufflink handlers in Rust that compile to WASM.
This crate wraps the raw WASM host ABI so you write normal Rust code
instead of pointer manipulation. Use it with cufflink services running
in WASM mode.
§Quick Start
ⓘ
use cufflink_fn::prelude::*;
cufflink_fn::init!();
handler!(hello, |req: Request| {
let name = req.body()["name"].as_str().unwrap_or("world");
Response::json(&json!({"message": format!("Hello, {}!", name)}))
});§Architecture
Organize your code in layers:
- Handlers (thin) — parse request, call operation, return response
- Operations (fat) — validation, business rules, orchestration
- Repos (data) — pure SQL via
db::query/db::execute
Modules§
- config
- Read service configuration values set via
cufflink config set. - db
- Database access — run SQL queries against your service’s tables.
- http
- Make HTTP requests from inside your WASM handler.
- log
- Structured logging from inside your WASM handler.
- nats
- Publish messages to NATS for event-driven communication.
- prelude
- Import everything you need to write handlers.
- redis
- Read and write values in Redis (backed by the platform’s Redis connection).
- storage
- Download files from S3-compatible object storage using the platform’s credentials.
- util
- Utility functions for common operations in WASM handlers.
Macros§
- handler
- Define a handler function.
- init
- Initialize the cufflink-fn runtime. Call this once at the top of your
lib.rs.