forked from swift-server/swift-http-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTTPServerClosureRequestHandler+HTTPService.swift
More file actions
48 lines (46 loc) · 1.72 KB
/
HTTPServerClosureRequestHandler+HTTPService.swift
File metadata and controls
48 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift HTTP Server open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift HTTP Server project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if ServiceLifecycle
public import AsyncStreaming
public import HTTPTypes
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
extension HTTPService
where
Handler == HTTPServerClosureRequestHandler<
Server.RequestReader,
Server.RequestReader.Underlying,
Server.ResponseWriter,
Server.ResponseWriter.Underlying
>
{
/// - Parameters:
/// - server: The underlying HTTPServer instance.
/// - serverHandler: The request handler closure.
/// - gracefulShutdownHandler: A closure to execute upon graceful shutdown.
public init(
server: Server,
serverHandler:
nonisolated(nonsending) @Sendable @escaping (
_ request: HTTPRequest,
_ requestContext: HTTPRequestContext,
_ requestBodyAndTrailers: consuming sending Server.RequestReader,
_ responseSender: consuming sending HTTPResponseSender<Server.ResponseWriter>
) async throws -> Void,
gracefulShutdownHandler: @Sendable @escaping () -> Void = {}
) {
self.server = server
self.serverHandler = HTTPServerClosureRequestHandler(handler: serverHandler)
self.gracefulShutdownHandler = gracefulShutdownHandler
}
}
#endif // ServiceLifecycle