You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Starts an HTTP server with a closure-based request handler.
84
+
///
85
+
/// This method provides a convenient way to start an HTTP server using a closure to handle incoming requests.
86
+
///
87
+
/// - Parameters:
88
+
/// - handler: An async closure that processes HTTP requests. The closure receives:
89
+
/// - `HTTPRequest`: The incoming HTTP request with headers and metadata.
90
+
/// - ``HTTPRequestContext``: The request's context.
91
+
/// - ``HTTPRequestConcludingAsyncReader``: An async reader for consuming the request body and trailers.
92
+
/// - ``HTTPResponseSender``: A non-copyable wrapper for a function that accepts an `HTTPResponse` and provides access to an ``HTTPResponseConcludingAsyncWriter``.
93
+
///
94
+
/// ## Example
95
+
///
96
+
/// ```swift
97
+
/// try await server.serve { request, bodyReader, responseSender in
98
+
/// // Process the request
99
+
/// let response = HTTPResponse(status: .ok)
100
+
/// let writer = try await responseSender.send(response)
101
+
/// try await writer.produceAndConclude { writer in
/// Starts an HTTP server with a closure-based request handler.
48
-
///
49
-
/// This method provides a convenient way to start an HTTP server using a closure to handle incoming requests.
50
-
///
51
-
/// - Parameters:
52
-
/// - handler: An async closure that processes HTTP requests. The closure receives:
53
-
/// - `HTTPRequest`: The incoming HTTP request with headers and metadata
54
-
/// - ``HTTPRequestConcludingAsyncReader``: An async reader for consuming the request body and trailers
55
-
/// - ``HTTPResponseSender``: A non-copyable wrapper for a function that accepts an `HTTPResponse` and provides access to an ``HTTPResponseConcludingAsyncWriter``
56
-
///
57
-
/// ## Example
58
-
///
59
-
/// ```swift
60
-
/// try await server.serve { request, bodyReader, sendResponse in
61
-
/// // Process the request
62
-
/// let response = HTTPResponse(status: .ok)
63
-
/// let writer = try await sendResponse(response)
64
-
/// try await writer.produceAndConclude { writer in
0 commit comments