Skip to content

Commit

Permalink
Update for non-generic HTTPChannelBuilder (#59)
Browse files Browse the repository at this point in the history
* Update for non-generic HTTPChannelBuilder

* Update for HB 2.0 beta 3

* Use 2.0.0 beta 4
  • Loading branch information
adam-fowler authored Apr 29, 2024
1 parent 1b9bdfc commit 81cda8c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
.library(name: "HummingbirdWSCompression", targets: ["HummingbirdWSCompression"]),
],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-beta.4"),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.62.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension HTTPChannelBuilder {
configuration: WebSocketServerConfiguration = .init(),
additionalChannelHandlers: @autoclosure @escaping @Sendable () -> [any RemovableChannelHandler] = [],
shouldUpgrade: @escaping @Sendable (HTTPRequest, Channel, Logger) async throws -> ShouldUpgradeResult<WebSocketDataHandler<BasicWebSocketContext>>
) -> HTTPChannelBuilder<HTTP1WebSocketUpgradeChannel> {
) -> HTTPChannelBuilder {
return .init { responder in
return HTTP1WebSocketUpgradeChannel(
responder: responder,
Expand All @@ -42,7 +42,7 @@ extension HTTPChannelBuilder {
configuration: WebSocketServerConfiguration = .init(),
additionalChannelHandlers: @autoclosure @escaping @Sendable () -> [any RemovableChannelHandler] = [],
shouldUpgrade: @escaping @Sendable (HTTPRequest, Channel, Logger) throws -> ShouldUpgradeResult<WebSocketDataHandler<BasicWebSocketContext>>
) -> HTTPChannelBuilder<HTTP1WebSocketUpgradeChannel> {
) -> HTTPChannelBuilder {
return .init { responder in
return HTTP1WebSocketUpgradeChannel(
responder: responder,
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdWebSocket/WebSocketRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ extension HTTPChannelBuilder {
webSocketRouter: WSResponderBuilder,
configuration: WebSocketServerConfiguration = .init(),
additionalChannelHandlers: @autoclosure @escaping @Sendable () -> [any RemovableChannelHandler] = []
) -> HTTPChannelBuilder<HTTP1WebSocketUpgradeChannel> where WSResponderBuilder.Responder.Context: WebSocketRequestContext {
) -> HTTPChannelBuilder where WSResponderBuilder.Responder.Context: WebSocketRequestContext {
let webSocketReponder = webSocketRouter.buildResponder()
return .init { responder in
return HTTP1WebSocketUpgradeChannel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import XCTest

final class HummingbirdWebSocketExtensionTests: XCTestCase {
func testClientAndServer(
serverChannel: HTTPChannelBuilder<HTTP1WebSocketUpgradeChannel>,
serverChannel: HTTPChannelBuilder,
clientExtensions: [WebSocketExtensionFactory] = [],
client clientHandler: @escaping WebSocketDataHandler<BasicWebSocketContext>
) async throws {
Expand Down
8 changes: 4 additions & 4 deletions Tests/HummingbirdWebSocketTests/WebSocketTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ final class HummingbirdWebSocketTests: XCTestCase {
}

@discardableResult func testClientAndServer(
serverChannel: HTTPChannelBuilder<some HTTPChannelHandler>,
serverChannel: HTTPChannelBuilder,
getClient: @escaping @Sendable (Int, Logger) throws -> WebSocketClient
) async throws -> WebSocketCloseFrame? {
try await withThrowingTaskGroup(of: Void.self) { group in
Expand Down Expand Up @@ -129,7 +129,7 @@ final class HummingbirdWebSocketTests: XCTestCase {
shouldUpgrade: @escaping @Sendable (HTTPRequest) throws -> HTTPFields? = { _ in return [:] },
getClient: @escaping @Sendable (Int, Logger) throws -> WebSocketClient
) async throws -> WebSocketCloseFrame? {
let webSocketUpgrade: HTTPChannelBuilder<some HTTPChannelHandler> = .http1WebSocketUpgrade { head, _, _ in
let webSocketUpgrade: HTTPChannelBuilder = .http1WebSocketUpgrade { head, _, _ in
if let headers = try shouldUpgrade(head) {
return .upgrade(headers, serverHandler)
} else {
Expand Down Expand Up @@ -173,7 +173,7 @@ final class HummingbirdWebSocketTests: XCTestCase {
webSocketRouter: Router<some WebSocketRequestContext>,
getClient: @escaping @Sendable (Int, Logger) throws -> WebSocketClient
) async throws -> WebSocketCloseFrame? {
let webSocketUpgrade: HTTPChannelBuilder<some HTTPChannelHandler> = .http1WebSocketUpgrade(webSocketRouter: webSocketRouter)
let webSocketUpgrade: HTTPChannelBuilder = .http1WebSocketUpgrade(webSocketRouter: webSocketRouter)
return try await self.testClientAndServer(
serverChannel: webSocketUpgrade,
getClient: getClient
Expand Down Expand Up @@ -540,7 +540,7 @@ final class HummingbirdWebSocketTests: XCTestCase {
router.ws("/ws") { inbound, _, _ in
for try await _ in inbound {}
}
let webSocketUpgrade: HTTPChannelBuilder<some HTTPChannelHandler> = .http1WebSocketUpgrade(
let webSocketUpgrade: HTTPChannelBuilder = .http1WebSocketUpgrade(
webSocketRouter: router,
configuration: .init(autoPing: .enabled(timePeriod: .milliseconds(50)))
)
Expand Down

0 comments on commit 81cda8c

Please sign in to comment.