HTTP Server #
This module defines a simple, asynchronous HTTP/1.1 server implementation.
It provides the Std.Http.Server structure, which encapsulates all server state, and functions for
starting, managing, and gracefully shutting down the server.
The server runs entirely using Async and uses a shared CancellationContext to signal shutdowns.
Each active client connection is tracked, and the server automatically resolves its shutdown
promise once all connections have closed.
The Server structure holds all state required to manage the lifecycle of an HTTP server, including
connection tracking and shutdown coordination.
- context : CancellationContext
The context used for shutting down all connections and the server.
Active HTTP connections
Semaphore used to enforce the maximum number of simultaneous active connections.
nonemeans no connection limit.Indicates when the server has successfully shut down.
- config : Config
Configuration of the server
- localAddr : Option Net.SocketAddress
The local socket address the server is bound to. When
serveis called with a port of0, this reflects the ephemeral port assigned by the OS rather than the requested address.nonefor servers constructed without an associated listening socket (e.g.serveConnection).
Instances For
Triggers cancellation of all requests and the accept loop in the server. This function should be used
in conjunction with waitShutdown to properly coordinate the shutdown sequence.
Instances For
Waits for the server to shut down. Blocks until another task or async operation calls the shutdown function.
Equations
- s.waitShutdown = do let __do_lift ← liftM s.shutdownPromise.recv Std.Async.Async.ofAsyncTask (Task.map Except.ok __do_lift)
Instances For
Returns a Selector that waits for the server to shut down.
Equations
Instances For
Triggers cancellation of all requests and the accept loop, then waits for the server to fully shut down.
This is a convenience function combining shutdown and then waitShutdown.
Equations
Instances For
Start a new HTTP/1.1 server on the given socket address. This function uses Async to handle tasks
and TCP connections, and returns a Server structure that can be used to cancel the server.
Equations
- One or more equations did not get rendered due to their size.