33namespace BeyondCode \LaravelWebSockets \Server ;
44
55use Ratchet \WebSocket \WsServer ;
6+ use Illuminate \Support \Collection ;
67use Symfony \Component \Routing \Route ;
78use Symfony \Component \Routing \RouteCollection ;
89use Ratchet \WebSocket \MessageComponentInterface ;
@@ -18,10 +19,12 @@ class Router
1819{
1920 /** @var \Symfony\Component\Routing\RouteCollection */
2021 protected $ routes ;
22+ protected $ customRoutes ;
2123
2224 public function __construct ()
2325 {
2426 $ this ->routes = new RouteCollection ;
27+ $ this ->customRoutes = new Collection ();
2528 }
2629
2730 public function getRoutes (): RouteCollection
@@ -39,6 +42,13 @@ public function echo()
3942 $ this ->get ('/apps/{appId}/channels/{channelName}/users ' , FetchUsersController::class);
4043 }
4144
45+ public function customRoutes ()
46+ {
47+ $ this ->customRoutes ->each (function ($ action , $ uri ) {
48+ $ this ->get ($ uri , $ action );
49+ });
50+ }
51+
4252 public function get (string $ uri , $ action )
4353 {
4454 $ this ->addRoute ('GET ' , $ uri , $ action );
@@ -70,7 +80,7 @@ public function webSocket(string $uri, $action)
7080 throw InvalidWebSocketController::withController ($ action );
7181 }
7282
73- $ this ->get ($ uri , $ action );
83+ $ this ->customRoutes -> put ($ uri , $ action );
7484 }
7585
7686 public function addRoute (string $ method , string $ uri , $ action )
0 commit comments