Skip to content

Commit

Permalink
Fix config path
Browse files Browse the repository at this point in the history
  • Loading branch information
Reindert Vetter committed Aug 20, 2019
1 parent 14d2822 commit 2ccd207
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/ApiVersionControlServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ public function boot()
'api-version-control-config'
);

// $this->app->middleware(
// [
// ApiVersionControl::class,
// ]
// );
/** @var \Illuminate\Routing\Router $router */
$router = $this->app['router'];
$router->pushMiddlewareToGroup('web', ApiVersionControl::class);
$router->pushMiddlewareToGroup('api', ApiVersionControl::class);
}
}
6 changes: 3 additions & 3 deletions src/Collection/MiddlewareCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($items = [], Request $request = null)
*/
public static function createFromConfig(Request $request)
{
$middlewareByPattern = config('api_version');
$middlewareByPattern = config('api_version_control');
$default = $middlewareByPattern['default'];
unset($middlewareByPattern['default']);

Expand All @@ -58,7 +58,7 @@ public static function createFromConfig(Request $request)
public function filterByVersionCompare(): self
{
/** @var \ReindertVetter\ApiVersionControl\Helper\VersionParser $versionParser */
$versionParser = app(config('api_version.version_parser'));
$versionParser = app(config('api_version_control.version_parser'));
$requestVersion = $versionParser->getVersion();

return $this->filter(
Expand Down Expand Up @@ -88,4 +88,4 @@ private function parseRawVersion(string $rawVersionRule): array
'version' => $result[2],
];
}
}
}
12 changes: 4 additions & 8 deletions src/Middleware/Version/ExampleThrowCustomException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
namespace ReindertVetter\ApiVersionControl\Middleware\Version;

use Closure;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ExampleThrowCustomException
{
use Logger;

/**
* @param $request
* @param \Closure $next
Expand All @@ -23,13 +19,13 @@ public function handle(Request $request, Closure $next)
$response = $next($request);

if ($response->exception) {
return response()->json(
$response->setContent(
[
"errors" => [
[
"human" => $ex->getMessage(),
]
]
"human" => $response->exception->getMessage(),
],
],
]
);
}
Expand Down

0 comments on commit 2ccd207

Please sign in to comment.