Merge branch 'master' of github.com:beyondcode/laravel-websockets

This commit is contained in:
Marcel Pociot 2018-12-04 10:15:43 +01:00
commit 09396cd92c
3 changed files with 10 additions and 18 deletions

View File

@ -56,6 +56,11 @@ return [
'interval_in_seconds' => 60, '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. * Define the optional SSL context for your WebSocket connections.
* You can see all available options at: http://php.net/manual/en/context.ssl.php * 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 $this
->registerRouteMacro() ->registerRoutes()
->registerStatisticRoute()
->registerDashboardGate(); ->registerDashboardGate();
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets'); $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets');
@ -60,23 +59,16 @@ class WebSocketsServiceProvider extends ServiceProvider
}); });
} }
protected function registerRouteMacro() protected function registerRoutes()
{ {
Route::macro('webSockets', function ($prefix = 'laravel-websockets') { Route::prefix(config('websockets.path'))->group(function() {
Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function () { Route::middleware(Authorize::class)->group(function() {
Route::get('/', ShowDashboard::class); Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', DashboardApiController::class . '@getStatistics'); Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
Route::post('auth', AuthenticateDashboard::class); Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class); Route::post('event', SendMessage::class);
}); });
});
return $this;
}
protected function registerStatisticRoute()
{
Route::prefix('/laravel-websockets')->namespace('\\')->group(function () {
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']); Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
}); });

View File

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