From 041354e5eba2bb928a504c1d9e1403687deeab04 Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 26 Nov 2018 23:24:24 +0100 Subject: [PATCH 1/3] commit --- config/websockets.php | 16 ---------------- src/Dashboard/Http/routes.php | 9 --------- src/WebSocketsServiceProvider.php | 25 +++++++++++-------------- 3 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 src/Dashboard/Http/routes.php diff --git a/config/websockets.php b/config/websockets.php index 2f4ffb1..2d52a54 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -29,22 +29,6 @@ return [ */ 'client_provider' => ConfigClientProvider::class, - 'dashboard' => [ - - /* - * Path for the Websockets debug dashboard - */ - 'path' => '/websockets', - - /* - * Middleware that will be applied to the dashboard routes. - */ - 'middleware' => [ - 'web', - Authorize::class, - ], - ], - /* * This array contains the hosts of which you want to allow incoming requests. * Leave this empty if you want to accepts requests from all hosts. diff --git a/src/Dashboard/Http/routes.php b/src/Dashboard/Http/routes.php deleted file mode 100644 index 99d0f6f..0000000 --- a/src/Dashboard/Http/routes.php +++ /dev/null @@ -1,9 +0,0 @@ -publishes([ __DIR__.'/../config/websockets.php' => base_path('config/websockets.php'), ], 'config'); - $this->registerRoutes(); + $this->registerRouteMacro(); $this->registerDashboardGate(); @@ -33,21 +34,17 @@ class WebSocketsServiceProvider extends ServiceProvider Event::subscribe(EventSubscriber::class); } - protected function registerRoutes() + protected function registerRouteMacro() { - Route::group($this->routeConfiguration(), function () { - $this->loadRoutesFrom(__DIR__.'/Dashboard/Http/routes.php'); + Route::macro('websocketsDashboard', function($prefix = 'websockets') { + Route::prefix($prefix)->middleware(Authorize::class)->group(function() { + Route::get('/', ShowDashboard::class); + Route::post('auth', AuthenticateDashboard::class); + Route::post('event', SendMessage::class); + }); }); } - protected function routeConfiguration() - { - return [ - 'prefix' => config('websockets.dashboard.path'), - 'middleware' => 'websockets', - ]; - } - public function register() { $this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets'); From 74137bb9f45949d1b907fb422b6627be231fd25c Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 26 Nov 2018 23:28:39 +0100 Subject: [PATCH 2/3] import middleware --- src/WebSocketsServiceProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WebSocketsServiceProvider.php b/src/WebSocketsServiceProvider.php index 7379574..f1171ca 100644 --- a/src/WebSocketsServiceProvider.php +++ b/src/WebSocketsServiceProvider.php @@ -6,6 +6,7 @@ use BeyondCode\LaravelWebSockets\Dashboard\EventSubscriber; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard; +use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Route; From 901db407cefb61f7e794d0599ff38eb379fa091a Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 26 Nov 2018 23:31:38 +0100 Subject: [PATCH 3/3] fix namespace --- src/WebSocketsServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WebSocketsServiceProvider.php b/src/WebSocketsServiceProvider.php index f1171ca..0d7cde8 100644 --- a/src/WebSocketsServiceProvider.php +++ b/src/WebSocketsServiceProvider.php @@ -38,8 +38,8 @@ class WebSocketsServiceProvider extends ServiceProvider protected function registerRouteMacro() { Route::macro('websocketsDashboard', function($prefix = 'websockets') { - Route::prefix($prefix)->middleware(Authorize::class)->group(function() { - Route::get('/', ShowDashboard::class); + Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function() { + Route::get('/', ShowDashboard::class); Route::post('auth', AuthenticateDashboard::class); Route::post('event', SendMessage::class); });