File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Sources/VaporRouteBuilder/RouteComponents Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,16 @@ Group(path: "movies", ":movie") {
123123}
124124```
125125
126+ ### Websockets
127+
128+ Defining a websocket is as simple as using the ` Socket ` route component.
129+
130+ ``` swift
131+ Group (path : " api" ) {
132+ Socket (" foo" ) { ... }
133+ }
134+ ```
135+
126136### Expressions & Logic
127137
128138` @ResultBuilder ` supports a wide variety of the available result builder syntax.
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ import Vapor
2525
2626// MARK: - Socket
2727
28+ /// A route component that defines a websocket at a given path.
29+ ///
30+ /// Use `Socket` in a route builder to define a websocket connection at the specified path.
31+ ///
32+ /// ```swift
33+ /// Group(path: "api") {
34+ /// Socket("foo") { ... }
35+ /// }
36+ /// ```
37+ ///
2838public struct Socket : RouteComponent {
2939
3040 // MARK: Properties
@@ -62,3 +72,9 @@ public struct Socket: RouteComponent {
6272 route
6373 }
6474}
75+
76+ // MARK: - RouteComponents + Socket
77+
78+ extension RouteComponents {
79+ public typealias Socket = VaporRouteBuilder . Socket
80+ }
You canβt perform that action at this time.
0 commit comments