API reference

fast-twitch.macros

Complete generated reference for fast-twitch.macros

Use macros at compile time

(ns application.bootstrap
  (:require [fast-twitch.routing :as routing]
            [fast-twitch.macros :refer-macros [serve shutdown env-var current-runtime]]))

;; Supply an already-adapted Fetch handler.
(def fetch-handler
  (routing/ft-handler (fn [_] (routing/response "Hello"))
                      {:protocol "HTTP/1.1" :remote-addr "unknown"}))
(def listener (serve :handler fetch-handler :hostname "127.0.0.1" :port 6464))
;; Await (shutdown listener :force true) during asynchronous cleanup.

serve accepts keyword arguments :app, :handler, :host, :hostname, :port, :on-listen, :reuse-port. App properties can supply handler/fetch, hostname, port, onListen and reusePort. Default hostname is loopback and port is 6464. Literal unknown keys and numeric ports outside integer 0–65535 fail during macro expansion; runtime-dependent values are checked at the native boundary.

current-runtime expands to runtime detection; env-var reads supported server environment APIs. These do not make Node APIs available in a Worker. shutdown delegates to the listener's runtime and supports forced shutdown where the adapter can provide it. The lower-level serve/shutdown helpers below generate forms; application code normally uses serve / shutdown or the simpler server.core functions.

Configured listener alternative · Complete Hello World project · Fetch-only Celld entry · Fetch-only workerd entry.

Upstream function reference

Macros for runtime detection, environment lookup, and native server startup.

current-runtime

(current-runtime)

Macro.

Expands to a keyword naming the active JavaScript runtime, or nil when unsupported. Source

env-var

(env-var v)

Macro.

Reads an environment variable from Deno or Node-compatible globals at runtime. Source

serve

(serve & {:keys [app handler host hostname port on-listen reuse-port], :as options})

Macro.

Starts a native HTTP server with the existing app/handler defaults. Unknown literal option names and invalid numeric literal ports fail at expansion. Source

serve-bun

(serve-bun bun handler hostname port on-listen reuse-port proxy)

Function. Source

serve-deno

(serve-deno deno handler hostname port on-listen reuse-port proxy)

Function. Source

serve-node

(serve-node process handler hostname port on-listen reuse-port proxy)

Function. Source

shutdown

(shutdown server & {:keys [force]})

Macro.

Stops a native server returned by serve; returns its shutdown completion. Source

shutdown-bun

(shutdown-bun server force)

Function. Source

shutdown-deno

(shutdown-deno server)

Function. Source

shutdown-node

(shutdown-node server force)

Function. Source

shutdown-registered

(shutdown-registered entry force)

Function. Source

shutdown-registry

(shutdown-registry)

Function. Source


Source revision a4eb73f96836d034c7a24fe09dc7d51e4c581f64

Built with Fast-Twitch · Integrant · Datastar

Search documentation

Search pages and API symbols

Start hereWelcome to Fast-TwitchRing HTTP applications and configured native clients and transports in ClojureScript.Start hereGetting startedCompile and run your first Fast-Twitch server.Core conceptsRequest & responseUnderstand the maps at the center of a Fast-Twitch application.Core conceptsRoutingMatch URL patterns and compose handlers.Core conceptsMiddlewareWrap handlers with focused request and response behavior.GuidesHTML & IntegrantCompose a UI system with Integrant and render Hiccup.