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

Add webSocket route overload with array path #2445

Merged
merged 1 commit into from Jul 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/Vapor/Routing/RoutesBuilder+WebSocket.swift
Expand Up @@ -16,6 +16,15 @@ extension RoutesBuilder {
_ path: PathComponent...,
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Should be marked @inlinable I think :)

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

The function that is, not the argument. GH didn't let me add the comment to the correct line :L

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No other routes are marked @inlinable, so why would these be?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. @inlinable would be good to add, but that's better served in a separate PR imo.

maxFrameSize: WebSocketMaxFrameSize = .`default`,
onUpgrade: @escaping (Request, WebSocket) -> ()
) -> Route {
return self.webSocket(path, maxFrameSize: maxFrameSize, onUpgrade: onUpgrade)
}

@discardableResult
public func webSocket(
_ path: [PathComponent],
maxFrameSize: WebSocketMaxFrameSize = .`default`,
onUpgrade: @escaping (Request, WebSocket) -> ()
) -> Route {
return self.on(.GET, path) { request -> Response in
let res = Response(status: .switchingProtocols)
Expand Down