This commit is contained in:
freek 2018-11-26 23:24:24 +01:00
parent ad97ca506a
commit 041354e5eb
3 changed files with 11 additions and 39 deletions

View File

@ -29,22 +29,6 @@ return [
*/ */
'client_provider' => ConfigClientProvider::class, '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. * 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. * Leave this empty if you want to accepts requests from all hosts.

View File

@ -1,9 +0,0 @@
<?php
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
Route::get('/', ShowDashboard::class);
Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class);

View File

@ -3,6 +3,9 @@
namespace BeyondCode\LaravelWebSockets; namespace BeyondCode\LaravelWebSockets;
use BeyondCode\LaravelWebSockets\Dashboard\EventSubscriber; 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 Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@ -14,13 +17,11 @@ class WebSocketsServiceProvider extends ServiceProvider
{ {
public function boot() public function boot()
{ {
Route::middlewareGroup('websockets', config('websockets.dashboard.middleware', []));
$this->publishes([ $this->publishes([
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'), __DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
], 'config'); ], 'config');
$this->registerRoutes(); $this->registerRouteMacro();
$this->registerDashboardGate(); $this->registerDashboardGate();
@ -33,19 +34,15 @@ class WebSocketsServiceProvider extends ServiceProvider
Event::subscribe(EventSubscriber::class); Event::subscribe(EventSubscriber::class);
} }
protected function registerRoutes() protected function registerRouteMacro()
{ {
Route::group($this->routeConfiguration(), function () { Route::macro('websocketsDashboard', function($prefix = 'websockets') {
$this->loadRoutesFrom(__DIR__.'/Dashboard/Http/routes.php'); 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() public function register()