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

Commit 4aab3d4

Browse files
committed
wip
1 parent e993457 commit 4aab3d4

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

config/websockets.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
'interval_in_seconds' => 60,
5757
],
5858

59+
/*
60+
* This path will be used to register the necessary routes for the package.
61+
*/
62+
'path' => 'laravel-websockets',
63+
5964
/*
6065
* Define the optional SSL context for your WebSocket connections.
6166
* You can see all available options at: http://php.net/manual/en/context.ssl.php

src/WebSocketsServiceProvider.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function boot()
3232
}
3333

3434
$this
35-
->registerRouteMacro()
36-
->registerStatisticRoute()
35+
->registerRoutes()
3736
->registerDashboardGate();
3837

3938
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets');
@@ -60,23 +59,14 @@ public function register()
6059
});
6160
}
6261

63-
protected function registerRouteMacro()
62+
protected function registerRoutes()
6463
{
65-
Route::macro('webSockets', function ($prefix = 'laravel-websockets') {
66-
Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function () {
67-
Route::get('/', ShowDashboard::class);
68-
Route::get('/api/{appId}/statistics', DashboardApiController::class . '@getStatistics');
69-
Route::post('auth', AuthenticateDashboard::class);
70-
Route::post('event', SendMessage::class);
71-
});
72-
});
64+
Route::prefix(config('websockets.path'))->middleware(Authorize::class)->group(function () {
65+
Route::get('/', ShowDashboard::class);
66+
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
67+
Route::post('auth', AuthenticateDashboard::class);
68+
Route::post('event', SendMessage::class);
7369

74-
return $this;
75-
}
76-
77-
protected function registerStatisticRoute()
78-
{
79-
Route::prefix('/laravel-websockets')->namespace('\\')->group(function () {
8070
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
8171
});
8272

tests/TestCase.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public function setUp()
2929

3030
$this->channelManager = app(ChannelManager::class);
3131

32-
/** TODO: make this work without middleware prefix */
33-
Route::middleware('App\Http\Controllers')->group(function() {
34-
Route::webSockets();
35-
});
36-
3732
StatisticsLogger::fake();
3833
}
3934

0 commit comments

Comments
 (0)