radiant

Package Version Hex Docs

A focused, type-safe HTTP router for Gleam on BEAM.

Built on a prefix tree with specificity-based priority, no global state, no macros.

gleam add radiant

Quick start

import gleam/int
import radiant

pub const user_id = radiant.int("id")

pub fn router() -> radiant.Router {
  radiant.new()
  |> radiant.get("/", fn(_req) { radiant.ok("hello") })
  |> radiant.get1("/users/<id:int>", user_id, fn(_req, id) {
    radiant.json("{\"id\":" <> int.to_string(id) <> "}")
  })
  |> radiant.scope("/api/v1", fn(r) {
    r |> radiant.post("/items", create_item)
  })
}

get1 hands the parsed Int directly to the handler — no let assert, no int.parse.

Why Radiant?

Gleam’s native routing is case wisp.path_segments(req) — great for small apps. Radiant adds:

Native pattern matchingRadiant
Type-safe path params
Specificity-based priority
405 Method Not Allowedmanual✅ automatic
HEAD support (RFC 9110)manual✅ automatic
Reverse routing
Route introspection
Built-in test helpers
CORS middleware
Query params (typed)manual

Features

Documentation

Non-goals

Radiant does not provide: template rendering, sessions, cookies, authentication, or WebSockets. Use the underlying server (Mist) or a full framework (Wisp) directly for those.

Development

gleam test    # Run the test suite
gleam dev     # Start the demo server on :4000
Search Document