Skip to content

Commit bfad054

Browse files
committed
πŸ“š Socket documentation.
1 parent ef3896f commit bfad054

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

β€ŽSources/VaporRouteBuilder/RouteComponents/Socket.swiftβ€Ž

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
///
2838
public 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+
}

0 commit comments

Comments
Β (0)