Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 041354e

Browse files
committed
commit
1 parent ad97ca5 commit 041354e

File tree

3 files changed

+11
-39
lines changed

3 files changed

+11
-39
lines changed

config/websockets.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,6 @@
2929
*/
3030
'client_provider' => ConfigClientProvider::class,
3131

32-
'dashboard' => [
33-
34-
/*
35-
* Path for the Websockets debug dashboard
36-
*/
37-
'path' => '/websockets',
38-
39-
/*
40-
* Middleware that will be applied to the dashboard routes.
41-
*/
42-
'middleware' => [
43-
'web',
44-
Authorize::class,
45-
],
46-
],
47-
4832
/*
4933
* This array contains the hosts of which you want to allow incoming requests.
5034
* Leave this empty if you want to accepts requests from all hosts.

src/Dashboard/Http/routes.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/WebSocketsServiceProvider.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
namespace BeyondCode\LaravelWebSockets;
44

55
use BeyondCode\LaravelWebSockets\Dashboard\EventSubscriber;
6+
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard;
7+
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
8+
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
69
use Illuminate\Support\Facades\Event;
710
use Illuminate\Support\Facades\Gate;
811
use Illuminate\Support\Facades\Route;
@@ -14,13 +17,11 @@ class WebSocketsServiceProvider extends ServiceProvider
1417
{
1518
public function boot()
1619
{
17-
Route::middlewareGroup('websockets', config('websockets.dashboard.middleware', []));
18-
1920
$this->publishes([
2021
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
2122
], 'config');
2223

23-
$this->registerRoutes();
24+
$this->registerRouteMacro();
2425

2526
$this->registerDashboardGate();
2627

@@ -33,21 +34,17 @@ public function boot()
3334
Event::subscribe(EventSubscriber::class);
3435
}
3536

36-
protected function registerRoutes()
37+
protected function registerRouteMacro()
3738
{
38-
Route::group($this->routeConfiguration(), function () {
39-
$this->loadRoutesFrom(__DIR__.'/Dashboard/Http/routes.php');
39+
Route::macro('websocketsDashboard', function($prefix = 'websockets') {
40+
Route::prefix($prefix)->middleware(Authorize::class)->group(function() {
41+
Route::get('/', ShowDashboard::class);
42+
Route::post('auth', AuthenticateDashboard::class);
43+
Route::post('event', SendMessage::class);
44+
});
4045
});
4146
}
4247

43-
protected function routeConfiguration()
44-
{
45-
return [
46-
'prefix' => config('websockets.dashboard.path'),
47-
'middleware' => 'websockets',
48-
];
49-
}
50-
5148
public function register()
5249
{
5350
$this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets');

0 commit comments

Comments
 (0)