Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Built-in API (natives)

Handlers call built-in functions provided by the runtime (often called natives). You do not import crates — if atlantus check accepts the name, the host implements it.

This page is the practical catalog for app authors. Prefer atlantus check for arity/type feedback on your version.

HTTP responses

CallResult
json(body) / ok(body)200 + JSON body
json(body, status)JSON with status (e.g. 201)
created(body)201 + JSON body
status(code)Status only (e.g. 204)
no_content()204 status only
not_found(msg?)404 JSON { error: "not_found", message? }
unauthorized(msg?)401 error envelope
forbidden(msg?)403 error envelope
bad_request(msg?)400 error envelope
unprocessable(msg_or_fields?)422 validation_failed
html(body)200 HTML
html(body, status)HTML with status
view(path, data)Render app/views/... → HTML response
view(path, data, status)Same with status
render_view(path, data)Render → string
render_template(tpl, data)Inline template → string

Status helpers desugar to http_json_response / http_status — same runtime as verbose forms.

Request

Call / sugarMeaning
req.param("id")Path param {id}
req.json()Parsed JSON body (or none)
req.header("authorization")Header
req.method()HTTP method
req.path()Path

Early-exit require helpers

Compiler sugar (expand to bind + early return), not separate host APIs:

Call / sugarMeaning
let x = require_found(expr, msg?)Value or 404 not_found
let x = require_json(req)JSON body or 422
let x = require_auth(req)auth_user_id(req) or 401
require_fields(map, ["a","b"])Statement; 422 if a field is missing

Control / null

Call / sugarMeaning
x is noneNull check
x is not nonePresent

Database (when SQLite/Postgres is enabled)

Exact names follow your CLI version — common pattern in product apps:

AreaExamples (check with your binary)
Querydb_query_one, db_query_all
Executedb_execute
Helperslist/get patterns used after atlantus db migrate

Always set:

export ATL_DATABASE_URL="sqlite:./tmp/app.db?mode=rwc"
atlantus db migrate --path .

See Database for a minimal flow. For a full working app tree, atlantus new + migrations is the supported starting point.

Auth (when enabled)

Typical surface (scaffold --with-auth / blog-style apps):

  • Password hash / verify natives
  • Token or session helpers (auth_user_id(req) — used by require_auth)
  • Login rate helpers

Production requires:

export ATL_ENV=production
export ATL_AUTH_SECRET='long-random-secret'

See Auth.

Jobs / events

Enqueue-style natives and a worker process for durable work — see Jobs.

Logging

CallMeaning
log_info(...)Structured/info log (host)

How to discover more

atlantus check --path .
# type errors name unknown or mis-arity natives
atlantus --help

When something is missing, upgrade the atlantus binary from Releases — do not install Rust to “get more APIs.”