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
where RequestHandler ==HTTPServerClosureRequestHandler<
48
-
HTTPRequestConcludingAsyncReader,
49
-
HTTPRequestConcludingAsyncReader.Underlying,
50
-
HTTPResponseConcludingAsyncWriter,
51
-
HTTPResponseConcludingAsyncWriter.Underlying
52
-
>{
53
-
/// Starts an HTTP server with a closure-based request handler.
54
-
///
55
-
/// This method provides a convenient way to start an HTTP server using a closure to handle incoming requests.
56
-
///
57
-
/// - Parameters:
58
-
/// - handler: An async closure that processes HTTP requests. The closure receives:
59
-
/// - `HTTPRequest`: The incoming HTTP request with headers and metadata
60
-
/// - ``HTTPRequestConcludingAsyncReader``: An async reader for consuming the request body and trailers
61
-
/// - ``HTTPResponseSender``: A non-copyable wrapper for a function that accepts an `HTTPResponse` and provides access to an ``HTTPResponseConcludingAsyncWriter``
62
-
///
63
-
/// ## Example
64
-
///
65
-
/// ```swift
66
-
/// try await server.serve { request, bodyReader, sendResponse in
67
-
/// // Process the request
68
-
/// let response = HTTPResponse(status: .ok)
69
-
/// let writer = try await sendResponse(response)
70
-
/// try await writer.produceAndConclude { writer in
0 commit comments