Connection #
This module defines Server.Connection, a structure used to handle a single HTTP connection with
possibly multiple requests.
Represents the remote address of a client connection.
- addr : Net.SocketAddress
The socket address of the remote client.
Instances For
@[implicit_reducible]
@[implicit_reducible]
Equations
- Std.Http.Server.instToStringRemoteAddr = { toString := fun (addr : Std.Http.Server.RemoteAddr) => toString addr.addr }
A single HTTP connection.
- socket : α
The client connection.
The processing machine for HTTP/1.1.
- extensions : Extensions
Extensions to attach to each request (e.g., remote address).
Instances For
def
Std.Http.Server.serveConnection
{t σ : Type}
[Transport t]
[Handler σ]
(client : t)
(handler : σ)
(config : Config)
(extensions : Extensions := Extensions.empty)
:
Handles request/response processing for a single connection using an Async handler.
The library-level entry point for running a server is Server.serve.
This function can be used with a TCP.Socket or any other type that implements
Transport to build custom server loops.
Example #
-- Create a TCP socket server instance
let server ← Socket.Server.mk
server.bind addr
server.listen backlog
-- Enter an infinite loop to handle incoming client connections
while true do
let client ← server.accept
background (serveConnection client handler config)
Equations
- One or more equations did not get rendered due to their size.