Skip to content

Commit

Permalink
Rename middleware option
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Oct 15, 2021
1 parent 4d500a1 commit c7b08fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ return [
'defaultStringLength' => 150,
],

'middleware' => [
'forceHttps' => app()->environment('production'),
'https' => [
'forceScheme' => app()->environment('production'),
'middleware' => app()->environment('production'),
],

'paginator' => [
Expand Down
5 changes: 3 additions & 2 deletions config/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
'defaultStringLength' => 150,
],

'middleware' => [
'forceHttps' => app()->environment('production'),
'https' => [
'forceScheme' => app()->environment('production'),
'middleware' => app()->environment('production'),
],

'paginator' => [
Expand Down
10 changes: 6 additions & 4 deletions src/UtilsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function boot()
$this->bootModel();
$this->bootLocale();
$this->bootSchema();
$this->bootMiddleware();
$this->bootHttps();
$this->bootPaginator();
}

Expand Down Expand Up @@ -89,16 +89,18 @@ private function bootSchema()
}

/**
* Bootstrap middleware.
* Bootstrap https.
*
* @return void
*/
private function bootMiddleware()
private function bootHttps()
{
if (config('utils.middleware.forceHttps')) {
if (config('utils.https.middleware')) {
$kernel = $this->app->make(Kernel::class);
$kernel->prependMiddleware(HttpsProtocolMiddleware::class);
}

if (config('utils.https.forceScheme')) {
URL::forceScheme('https');
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/CustomValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ protected function getEnvironmentSetUp($app)
'defaultStringLength' => null,
],

'middleware' => [
'forceHttps' => true,
'https' => [
'forceScheme' => true,
'middleware' => true,
],

'paginator' => [
Expand Down

0 comments on commit c7b08fd

Please sign in to comment.