You write routes. Viltrum owns the wire.
An HTTP framework for V with its own HTTP/1.1 engine: one epoll worker per CPU, pipelining, no allocation per request inside the framework, and no third-party code underneath.
git clone https://github.com/Tuntii/viltrum.git
Signs you in as admin@example.com. Everything lives in memory.
The route a request takes
- AcceptOne SO_REUSEPORT epoll worker per CPU
- ParseIn place, no allocation; ambiguous framing gets 400
- Route:param, *rest, groups, middleware
- HandlerYour fn (mut c Ctx)
- WritePipelined responses batched into one write
Live Viltrum 1.5.0 workers 2 resident 7.8 MB up 3:36:24 requests served 1895 in memory 0 items, 1 user
A server in one file.
Handlers get a Ctx: request views (path, param, query_param, header, body) and a response writer (text, json, bytes, file).
Request strings are views into the connection's buffer, valid until the handler returns. .clone() what you keep.
module main
import viltrum
fn main() {
mut app := viltrum.new()
app.use(viltrum.recover)
app.get('/', fn (mut c viltrum.Ctx) {
c.text(200, 'ok\n')
})
app.get('/hi/:name', fn (mut c viltrum.Ctx) {
c.text(200, c.param('name') or { 'world' })
})
app.listen('127.0.0.1:8080') or { panic(err) }
}
What the core does.
Everything below is in the framework itself, written for it. Serving is Linux only (epoll); handlers build and test on Linux, macOS and Windows.
Not in the 1.x core yet: the HTTP client, serving off Linux.
- HTTP/1.1
- Keep-alive, pipelining,
Expect: 100-continue, HEAD. The parser is fuzzed in CI. - Engine
- Backpressure, read, idle and write timeouts,
max_conns, graceful shutdown on SIGINT and SIGTERM. - Routing
- Parameters, trailing wildcards, groups, global and per-route middleware.
- JSON
c.json(200, value)with a compile-time encoder, no reflection.- TLS
- TLS 1.3 on the same workers; certificates reload from disk without a restart.
- Files
- ETag, Last-Modified, 304, byte ranges,
sendfilefor large files. - Forms
- urlencoded and multipart bodies parsed in place, no allocation.
- WebSocket
- RFC 6455 on the same workers, topics published across workers.
- Tests
app.handle_raw(raw)serves a request in-process, no socket.
This demo is the starter.
The page you are reading, the dashboard behind the sign-in and the JSON API are one V binary built from full-stack-viltrum-template: server-rendered pages with $tmpl, a cookie session, and an in-memory store.
The API takes the same cookie or a Bearer token.
curl -s https://v.rustapi.cloud/api/v1/health
{"status":"ok"}
curl -s -X POST https://v.rustapi.cloud/api/v1/login/access-token \
-d 'username=admin%40example.com&password=changethis'