Skip to content
All guides

servers

Servers and APIs

Keel (std.keel) is the one obvious way to run a Buraaq service. Sockets, TLS, accept loops, headers, table schema, REST, CORS, and health checks belong in the runtime. Your source declares what to serve.

std.service is the same module under the old name.

The whole program

fn main() {
    page("/", "public/index.html")
    api("items", "title, body")
    run()
}

Unique names import themselves in a project. use std.keel.{page, api, run} is still valid when you want it explicit. Split files with use sibling.item: modules. The banking CLI grows into this: the ledger as an app.

That program:

  • Serves public/index.html at /
  • Creates a Postgres table items with title and body
  • Exposes REST at /api/items and /api/items/:id
  • Serves /api/health
  • Listens TLS first (port 8443) and HTTP beside it (port 8080)
  • Handles CORS preflight (OPTIONS)

Do not write listen/accept/reply loops for ordinary APIs. Use std.http only to call other APIs.

Why this is fast and simple

The accept path is native LLVM, not an interpreter in a container. TLS is the default, not a reverse-proxy homework. You keep Python-shaped source (page, api, run) while the runtime owns the sockets.

Limits in this runtime: 32 pages, 16 APIs, 8 fields per API.

This track

  1. Your first API
  2. REST in depth
  3. Pages and TLS
  4. Postgres
  5. CLI and editors

Then Ship: hashed .bur, not Docker.