on master help sign in
Sources/App/configure.swift+6
since splitsnapshots
unifiedsplit
@@ -54,6 +54,12 @@ public func configure(_ config: inout Config, _ env: inout Environment, _ servic
54 }
54 }
55 }
55 }
56
56
57+ ws.get("test") { (ws, req) in
58+ ws.onText({ (ws, text) in
59+ ws.send("pong")
60+ })
61+ }
62+
57 services.register(ws, as: WebSocketServer.self)
63 services.register(ws, as: WebSocketServer.self)
58
64
59}
65}
Sources/App/routes.swift+4
@@ -16,6 +16,10 @@ public func routes(_ router: Router) throws {
16 return postModel.getPost(for: try req.parameters.next(Int.self), on: req)
16 return postModel.getPost(for: try req.parameters.next(Int.self), on: req)
17 }
17 }
18
18
19+ router.get("openSockets") { (req) in
20+ return OpenSockets.sockets.count
21+ }
22+
19 // Example of configuring a controller
23 // Example of configuring a controller
20 let todoController = TodoController()
24 let todoController = TodoController()
21 router.get("todos", use: todoController.index)
25 router.get("todos", use: todoController.index)