Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions config/websockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@
*/
'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.
* Leave this empty if you want to accepts requests from all hosts.
Expand Down
9 changes: 0 additions & 9 deletions src/Dashboard/Http/routes.php

This file was deleted.

26 changes: 12 additions & 14 deletions src/WebSocketsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace BeyondCode\LaravelWebSockets;

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 BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
Expand All @@ -14,13 +18,11 @@ class WebSocketsServiceProvider extends ServiceProvider
{
public function boot()
{
Route::middlewareGroup('websockets', config('websockets.dashboard.middleware', []));

$this->publishes([
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
], 'config');

$this->registerRoutes();
$this->registerRouteMacro();

$this->registerDashboardGate();

Expand All @@ -33,21 +35,17 @@ public function boot()
Event::subscribe(EventSubscriber::class);
}

protected function registerRoutes()
protected function registerRouteMacro()
{
Route::group($this->routeConfiguration(), function () {
$this->loadRoutesFrom(__DIR__.'/Dashboard/Http/routes.php');
Route::macro('websocketsDashboard', function($prefix = 'websockets') {
Route::prefix($prefix)->namespace('\\')->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()
{
$this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets');
Expand Down