This commit is contained in:
freek 2018-12-04 10:06:26 +01:00
parent e993457a80
commit 4aab3d441f
3 changed files with 12 additions and 22 deletions

View File

@ -56,6 +56,11 @@ return [
'interval_in_seconds' => 60,
],
/*
* This path will be used to register the necessary routes for the package.
*/
'path' => 'laravel-websockets',
/*
* Define the optional SSL context for your WebSocket connections.
* You can see all available options at: http://php.net/manual/en/context.ssl.php

View File

@ -32,8 +32,7 @@ class WebSocketsServiceProvider extends ServiceProvider
}
$this
->registerRouteMacro()
->registerStatisticRoute()
->registerRoutes()
->registerDashboardGate();
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets');
@ -60,23 +59,14 @@ class WebSocketsServiceProvider extends ServiceProvider
});
}
protected function registerRouteMacro()
protected function registerRoutes()
{
Route::macro('webSockets', function ($prefix = 'laravel-websockets') {
Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function () {
Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', DashboardApiController::class . '@getStatistics');
Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class);
});
});
Route::prefix(config('websockets.path'))->middleware(Authorize::class)->group(function () {
Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class);
return $this;
}
protected function registerStatisticRoute()
{
Route::prefix('/laravel-websockets')->namespace('\\')->group(function () {
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
});

View File

@ -29,11 +29,6 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
$this->channelManager = app(ChannelManager::class);
/** TODO: make this work without middleware prefix */
Route::middleware('App\Http\Controllers')->group(function() {
Route::webSockets();
});
StatisticsLogger::fake();
}