API reference

fast-twitch.routing

Complete generated reference for fast-twitch.routing

Using this namespace

(ns application.routing
  (:require [fast-twitch.routing :as routing]))

(def app
  (routing/routes
    [{:pattern "/hello/:name" :method :get
      :handler (fn [request]
                 (routing/response (str "Hello " (get-in request [:path-params :name]))))}]
    (fn [_] (routing/not-found "Missing"))))

(def fetch-handler
  (routing/ft-handler app {:protocol "HTTP/1.1" :remote-addr "unknown"}))

Route fields are :pattern (pathname string/native URLPattern), optional :method (keyword/string/sequence), and :handler or :async-handler. First match wins. Path groups become keyword keys under :path-params; URL query data is parsed separately by middleware. The fallback is a handler function supplied as the second argument to routes.

ft-handler takes [ring-handler options] and returns a Fetch-compatible function. Options require protocol and remote-addr; optional async? selects [request respond raise] callbacks. A normal handler returning a Promise uses the normal one-argument contract without async? true.

Complete routing walkthrough · All request/response fields · Complete request example · Server lifecycle.

Upstream function reference

Routing and handler adaptation helpers for translating between Fetch APIs and request maps.

build-request-map

(build-request-map request options)
(build-request-map request params options)

Function. Source

ft-handler

(ft-handler handler options)

Function.

Wraps an application handler as a Fetch-compatible function. Source

(header response name value)

Function.

Associates a header value on a response map. Source

not-found

(not-found body)

Function.

Builds a 404 response map with the supplied body. Source

proxy

Source

response

(response body)

Function.

Builds a 200 response map with the supplied body. Source

response?

(response? response)

Function.

Returns true when a value matches the expected response map shape. Source

routes

(routes routes default-handler)

Function.

Builds a dispatching handler from route definitions and a fallback handler. Source

server*

Source

start-server!

(start-server! app)
(start-server! handler options)

Function.

Starts the runtime adapter for an application or handler. Source

status

(status status)
(status response status)

Function.

Creates a bare response for a status code or updates an existing response map. Source

stop-server!

(stop-server! & {:keys [force callback]})

Function. Source

url-pattern

(url-pattern pathname)

Function.

Builds a URLPattern that matches the given pathname. 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.