REST APIs

Routing multiple endpoints

Use REST mode when you need more than one path under a shared base URL.

Example router

api.basilrouter
fn handle(req):
  if req.path == "/v1/ping":
    return { status: 200, body: "pong" }
  if req.path == "/v1/version":
    return { status: 200, body: "1" }
  return { status: 404, body: "not found" }
Tip: keep routes small and composable. For bigger APIs, consider a dedicated service.