API reference

fast-twitch.server.core

Complete generated reference for fast-twitch.server.core

Using this namespace

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

(def listener
  (server/listen!
    (fn [_] (server/response "Hello" {:headers {"content-type" "text/plain"}}))
    {:transport :http :hostname "127.0.0.1" :port 6464}))

HTTP listeners take an ordinary Ring handler and perform Fetch adaptation themselves. server/response creates a response map; options are status, headers and an optional JSON codec. TCP listeners take a connection callback and return a different handle. Listener readiness and shutdown follow the native runtime: use :on-listen for HTTP addresses, await TCP startup where needed, and await shutdown during application cleanup.

Full listener/response option tables · TCP options · Complete HTTP example · Complete TCP example.

Closing an HTTP server accepts :force; closing a TCP listener/peer accepts no options. Ring WebSocket close options are code/reason. Do not use one transport's close map for another. Each accepted TCP peer has a lifetime separate from its listener.

Upstream function reference

Ring HTTP response helpers and native servers configured with option maps.

close!

(close! handle)
(close! handle options)

Function.

Closes a native HTTP server, TCP listener/peer or Ring WebSocket. HTTP options: :force; WebSocket options: :code/:reason; TCP accepts no close options. Source

listen!

(listen! handler options)

Function.

Starts a server for a handler and configuration. :transport is :http (default) or :tcp. HTTP :codec :native preserves Ring bodies; :bytes/:text/:json decode present request bodies using :streaming settings, and JSON encodes HTTP response bodies. Standard Ring handler arities and :async? remain available. TCP supports :native/:bytes/:text; each connection carries its codec/streaming settings for client/send! and client/receive!. Reads continue through EOF without framing. Native options belong to the selected transport; invalid combinations reject before listening. Returns the existing native server/listener handle. Source

response

(response body)
(response body options)

Function.

Returns a Ring HTTP response map for body, with optional :status/:headers and :codec (:native by default, or :json for ordinary JSON data). 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.