Skip to content

Commit

Permalink
Add new versions of .tls and .http2Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Feb 11, 2025
1 parent 672f8b6 commit 309d38e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Sources/HummingbirdHTTP2/HTTPServerBuilder+http2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,30 @@ extension HTTPServerBuilder {
)
}
}

/// Build HTTP channel with HTTP2 upgrade
///
/// Use in ``Hummingbird/Application`` initialization.
/// ```
/// let app = Application(
/// router: router,
/// server: .http2Upgrade(configuration: .init(tlsConfiguration: tlsConfiguration))
/// )
/// ```
/// - Parameters:
/// - tlsConfiguration: TLS configuration
/// - configuration: HTTP2 Upgrade channel configuration
/// - Returns: HTTPChannelHandler builder
public static func http2Upgrade(
tlsChannelConfiguration: TLSChannelConfiguration,
configuration: HTTP2UpgradeChannel.Configuration = .init()
) throws -> HTTPServerBuilder {
.init { responder in
try HTTP2UpgradeChannel(
tlsChannelConfiguration: tlsChannelConfiguration,
configuration: configuration,
responder: responder
)
}
}

Check warning on line 98 in Sources/HummingbirdHTTP2/HTTPServerBuilder+http2.swift

View check run for this annotation

Codecov / codecov/patch

Sources/HummingbirdHTTP2/HTTPServerBuilder+http2.swift#L90-L98

Added lines #L90 - L98 were not covered by tests
}
22 changes: 22 additions & 0 deletions Sources/HummingbirdTLS/HTTPServerBuilder+tls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,26 @@ extension HTTPServerBuilder {
try base.buildChildChannel(responder).withTLS(tlsConfiguration: tlsConfiguration)
}
}

/// Build server supporting HTTP with TLS
///
/// Use in ``Hummingbird/Application`` initialization.
/// ```
/// let app = Application(
/// router: router,
/// server: .tls(.http1(), tlsConfiguration: tlsConfiguration)
/// )
/// ```
/// - Parameters:
/// - base: Base child channel to wrap with TLS
/// - configuration: TLS channel configuration
/// - Returns: HTTPChannelHandler builder
public static func tls(
_ base: HTTPServerBuilder = .http1(),
configuration: TLSChannelConfiguration
) throws -> HTTPServerBuilder {
.init { responder in
try base.buildChildChannel(responder).withTLS(configuration: configuration)
}
}

Check warning on line 61 in Sources/HummingbirdTLS/HTTPServerBuilder+tls.swift

View check run for this annotation

Codecov / codecov/patch

Sources/HummingbirdTLS/HTTPServerBuilder+tls.swift#L57-L61

Added lines #L57 - L61 were not covered by tests
}

0 comments on commit 309d38e

Please sign in to comment.