Skip to content

Commit 1746047

Browse files
qschmickroshangautam
authored andcommitted
refactor : expose config params to use custom web and api middleware
• Add config params to override default web and api middleware through environment variables.
1 parent c819302 commit 1746047

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Totem::auth(function($request) {
8383

8484
By default Totem's dashboard only works in local environment. To view the dashboard point your browser to /totem of your app. For e.g. laravel.dev/totem.
8585

86+
#### Middleware
87+
88+
`Laravel Totem` uses the default web and api middleware but if customization is required the middleware can be changed by setting the appropriate `.env` value. These values can be found in `config/totem.php`.
89+
8690
#### Making Commands available in `Laravel Totem`
8791

8892
All artisan commands can be scheduled. If you want to hide a command from Totem make sure you have the `hidden` attribute set to true in your command. For e.g.

config/totem.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,10 @@
216216
],
217217
],
218218
],
219+
'web' => [
220+
'middleware' => env('TOTEM_WEB_MIDDLEWARE', 'web'),
221+
],
222+
'api' => [
223+
'middleware' => env('TOTEM_API_MIDDLEWARE', 'api'),
224+
],
219225
];

src/Providers/TotemRouteServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function map()
5252
protected function mapWebRoutes()
5353
{
5454
Route::prefix('totem')
55-
->middleware('web')
55+
->middleware(config('totem.web.middleware'))
5656
->namespace($this->namespace)
5757
->group(__DIR__.'/../../routes/web.php');
5858
}
@@ -67,7 +67,7 @@ protected function mapWebRoutes()
6767
protected function mapApiRoutes()
6868
{
6969
Route::prefix('api')
70-
->middleware('api')
70+
->middleware(config('totem.web.middleware'))
7171
->namespace($this->namespace)
7272
->group(__DIR__.'/../../routes/api.php');
7373
}

0 commit comments

Comments
 (0)