Skip to content

Commit 93182a1

Browse files
committed
feat: improve comment of serveConnection
1 parent e37057f commit 93182a1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/Std/Internal/Http/Server/Connection.lean

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,28 @@ private def handle
188188
end Connection
189189

190190
/--
191-
Serve conection
191+
This is the entry point of the library. It is used to receive and send requests using an `Async`
192+
handler for a single connection. It can be used with a `TCP.Socket` or any other type that implements
193+
`ClientConnection` to create a simple HTTP server capable of handling multiple connections concurrently.
194+
195+
# Example
196+
197+
```lean
198+
-- Create a TCP socket server instance
199+
let server ← Socket.Server.mk
200+
server.bind addr
201+
server.listen backlog
202+
203+
-- Enter an infinite loop to handle incoming client connections
204+
while true do
205+
-- Accept a new client connection.
206+
let client ← server.accept
207+
208+
-- Handle the client connection concurrently in the background `serveConnection` will process requests
209+
-- and handle failures using the provided callbacks and config
210+
background (serveConnection client onRequest onFailure config)
211+
```
212+
192213
-/
193214
def serveConnection
194215
[ClientConnection t]

0 commit comments

Comments
 (0)