Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in documentation brought up by docc v6 #80

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/HummingbirdWSClient/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
//
//===----------------------------------------------------------------------===//

@_exported import HummingbirdWSCore
@_exported @_documentation(visibility: internal) import HummingbirdWSCore
2 changes: 1 addition & 1 deletion Sources/HummingbirdWSClient/WebSocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import NIOWebSocket
/// }
/// ```
public struct WebSocketClient {
/// Basic context implementation of ``WebSocketContext``.
/// Basic context implementation of ``/HummingbirdWSCore/WebSocketContext``.
/// Used by non-router web socket handle function
public struct Context: WebSocketContext {
public let logger: Logger
Expand Down
1 change: 0 additions & 1 deletion Sources/HummingbirdWSCore/WebSocketExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public struct WebSocketExtensionHTTPParameters: Sendable, Equatable {
/// Parse all `Sec-WebSocket-Extensions` header values
/// - Parameters:
/// - headers: headers coming from other
/// - type: client or server
/// - Returns: Array of extensions
public static func parseHeaders(_ headers: HTTPFields) -> [WebSocketExtensionHTTPParameters] {
let extHeaders = headers[values: .secWebSocketExtensions]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension WebSocketInboundStream {
/// converts the inbound stream of WebSocket data frames into a sequence of WebSocket
/// messages.
///
/// - Parameter maxMessageSize: The maximum size of message we are allowed to create
/// - Parameter maxSize: The maximum size of message we are allowed to read
public func messages(maxSize: Int) -> WebSocketInboundMessageStream {
.init(inboundStream: self, maxSize: maxSize)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdWebSocket/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
//
//===----------------------------------------------------------------------===//

@_exported import HummingbirdWSCore
@_exported @_documentation(visibility: internal) import HummingbirdWSCore
23 changes: 16 additions & 7 deletions Sources/HummingbirdWebSocket/WebSocketChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
public let channel: Channel
}

/// Basic context implementation of ``WebSocketContext``.
/// Basic context implementation of ``/HummingbirdWSCore/WebSocketContext``.
/// Used by non-router web socket handle function
public struct Context: WebSocketContext {
public let logger: Logger
Expand All @@ -51,11 +51,10 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl

/// Initialize HTTP1AndWebSocketChannel with synchronous `shouldUpgrade` function
/// - Parameters:
/// - additionalChannelHandlers: Additional channel handlers to add
/// - responder: HTTP responder
/// - maxFrameSize: Max frame size WebSocket will allow
/// - configuration: WebSocket configuration
/// - additionalChannelHandlers: Additional channel handlers to add
/// - shouldUpgrade: Function returning whether upgrade should be allowed
/// - Returns: Upgrade result future
public init(
responder: @escaping HTTPChannelHandler.Responder,
configuration: WebSocketServerConfiguration,
Expand Down Expand Up @@ -97,13 +96,23 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
self.responder = responder
}

@available(*, deprecated, renamed: "init(responder:configuration:additionalChannelHandlers:shouldUpgrade:)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this init needed for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the old init. Basically I got the arguments in the wrong order, so there was an inconsistency between the two init functions. So I've deprecated one of the old ones and replaced it with a new version with consistent argument order.

@_documentation(visibility: internal)
public init(
responder: @escaping HTTPChannelHandler.Responder,
additionalChannelHandlers: @escaping @Sendable () -> [any RemovableChannelHandler] = { [] },
configuration: WebSocketServerConfiguration,
shouldUpgrade: @escaping @Sendable (HTTPRequest, Channel, Logger) async throws -> ShouldUpgradeResult<WebSocketDataHandler<Context>>
) {
self.init(responder: responder, configuration: configuration, additionalChannelHandlers: additionalChannelHandlers, shouldUpgrade: shouldUpgrade)
}

/// Initialize HTTP1AndWebSocketChannel with async `shouldUpgrade` function
/// - Parameters:
/// - additionalChannelHandlers: Additional channel handlers to add
/// - responder: HTTP responder
/// - maxFrameSize: Max frame size WebSocket will allow
/// - additionalChannelHandlers: Additional channel handlers to add
/// - configuration: WebSocket configuration
/// - shouldUpgrade: Function returning whether upgrade should be allowed
/// - Returns: Upgrade result future
public init(
responder: @escaping HTTPChannelHandler.Responder,
configuration: WebSocketServerConfiguration,
Expand Down
13 changes: 6 additions & 7 deletions Sources/HummingbirdWebSocket/WebSocketRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension RouterMethods {
/// - Parameters:
/// - path: Path to match
/// - shouldUpgrade: Should request be upgraded
/// - handler: WebSocket channel handler
/// - handler: WebSocket channel handler function
@discardableResult public func ws(
_ path: RouterPath = "",
shouldUpgrade: @Sendable @escaping (Request, Context) async throws -> RouterShouldUpgrade = { _, _ in .upgrade([:]) },
Expand Down Expand Up @@ -115,7 +115,7 @@ public struct WebSocketUpgradeMiddleware<Context: WebSocketRequestContext>: Rout
/// Initialize WebSocketUpgradeMiddleare
/// - Parameters:
/// - shouldUpgrade: Return whether the WebSocket upgrade should occur
/// - handle: WebSocket handler
/// - handler: WebSocket handler function
public init(
shouldUpgrade: @Sendable @escaping (Request, Context) async throws -> RouterShouldUpgrade = { _, _ in .upgrade([:]) },
onUpgrade handler: @escaping WebSocketDataHandler<WebSocketRouterContext<Context>>
Expand All @@ -140,11 +140,10 @@ public struct WebSocketUpgradeMiddleware<Context: WebSocketRequestContext>: Rout
extension HTTP1WebSocketUpgradeChannel {
/// Initialize HTTP1WebSocketUpgradeChannel with async `shouldUpgrade` function
/// - Parameters:
/// - additionalChannelHandlers: Additional channel handlers to add
/// - responder: HTTP responder
/// - maxFrameSize: Max frame size WebSocket will allow
/// - webSocketRouter: WebSocket router
/// - Returns: Upgrade result future
/// - webSocketResponder: WebSocket initial request responder
/// - configuration: WebSocket configuration
/// - additionalChannelHandlers: Additional channel handlers to add
public init<WSResponder: HTTPResponder>(
responder: @escaping HTTPChannelHandler.Responder,
webSocketResponder: WSResponder,
Expand Down Expand Up @@ -207,7 +206,7 @@ extension HTTPServerBuilder {
/// - webSocketRouter: Router used for testing whether a WebSocket upgrade should occur
/// - configuration: WebSocket server configuration
/// - additionalChannelHandlers: Additional channel handlers to add to channel pipeline
/// - Returns:
/// - Returns: HTTP server builder that builds an HTTP1 with WebSocket upgrade server
public static func http1WebSocketUpgrade<WSResponderBuilder: HTTPResponderBuilder>(
webSocketRouter: WSResponderBuilder,
configuration: WebSocketServerConfiguration = .init(),
Expand Down
Loading