The Prism Server
PrismHTTPServer is a Swift actor built on Apple’s Network.framework. It handles TCP connections, HTTP parsing, routing, and middleware — all without a single third-party dependency.
Because
PrismHTTPServer is an actor, every interaction is concurrency-safe by default. You never need to worry about data races when registering routes or adding middleware.Creating a Server
main.swift
Configuration
Host and Port
Host and Port
TLS / HTTPS
TLS / HTTPS
Prism supports TLS natively via Network.framework — no OpenSSL needed.
Custom Logger
Custom Logger
Registering Routes
Register routes using the HTTP method helpers:Route Registration
Adding Middleware
Middleware runs on every request, in the order you add it:Middleware Stack
Route Groups
Group related routes under a shared prefix with optional group-specific middleware:Route Groups
Server Lifecycle
Start and Stop
PrismGracefulShutdown to drain connections before stopping:
Graceful Shutdown
Full Example
Here’s a complete server with routing, middleware, database, and error handling:Complete Server
Routing
Learn about path parameters, wildcards, and route groups.
Middleware
Build custom middleware and understand the execution chain.