Expand description
§ullun-api
Express.js-inspired web framework for Rust.
§Quick Start
use ullun::prelude::*;
#[tokio::main]
async fn main() {
App::new()
.get_with_params("/hello/{name}", |params: Params| async move {
Ok(Response::json(serde_json::json!({
"message": format!("Hello, {}!", params.get("name").unwrap())
})))
})
.run("127.0.0.1:3000")
.await
.unwrap();
}§Optional features
| Feature | Adds |
|---|---|
jwt | ullun::jwt - HS256 tokens and bearer-auth middleware |
compression | ullun::compression - gzip middleware |
websocket | App::ws and ullun::websocket |
full | all of the above |
Always available: rate_limit, openapi, template, form parsing
(Request::form) and group-level middleware.
Modules§
- app
- Main application orchestrator
- cache
- Server-side response cache with request coalescing and stale-while-revalidate
- client
- Outbound HTTP client
- compression
- Gzip response compression middleware (feature
compression) - conditional
- ETags and conditional requests
- cookies
- Cookie parsing and management
- cors
- Cross-origin resource sharing (CORS)
- csrf
- CSRF protection for cookie-authenticated forms and APIs
- error
- Error types and Result alias
- files
- Serving files from disk
- handler
- Handler traits and types
- health
- Liveness and readiness endpoints
- hub
- Publish/subscribe rooms
- idempotency
- Idempotency keys for unsafe requests
- jobs
- In-process job queue with retries
- jwt
- HS256 JSON Web Tokens and a bearer-token middleware (feature
jwt) - limits
- Resilience limits: request timeouts, load shedding and connection caps
- middleware
- Middleware types and traits
- multipart
multipart/form-datarequest bodies (file uploads and mixed forms)- negotiate
- Content negotiation (
Accept,Accept-Language) - observability
- Request ids, access logs and Prometheus metrics
- openapi
- OpenAPI 3.1 document generated from the registered routes
- prelude
- problem
- RFC 9457 problem details for error responses
- rate_
limit - In-memory rate limiting middleware
- request
- Request types and extractors
- response
- Response types and builders
- router
- Router implementation using matchit
- secure
- HTTPS policy: redirect plain HTTP, send HSTS
- security
- Small security helpers: secure random tokens and constant-time comparison
- security_
headers - Security response headers, including a Content-Security-Policy builder
- session
- Cookie-based server-side sessions
- shutdown
- Shutdown signal and background tasks
- sse
- Server-Sent Events
- static_
files - Static file serving
- stream
- Streaming response bodies
- template
- Server-side HTML templates
- testing
- Test an
Appin-process, without sockets - tls
- HTTPS (feature
tls) - validate
- Collect all problems of a request instead of failing on the first one
- websocket
- WebSocket endpoints (feature
websocket)