Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nasrulhazim committed Jul 27, 2018
2 parents 390a007 + 1648f99 commit 0126770
Show file tree
Hide file tree
Showing 6 changed files with 492 additions and 719 deletions.
6 changes: 2 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Kernel extends HttpKernel
],

'api' => [
\App\Http\Middleware\ApiHeader::class,
'api.header',
'throttle:60,1',
'bindings',
],
Expand All @@ -62,8 +62,6 @@ class Kernel extends HttpKernel
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'minify' => \App\Http\Middleware\MinifyHtml::class,
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
'theme' => \CleaniqueCoders\Themer\Http\Middleware\ThemeLoader::class,
'api.header' => \App\Http\Middleware\ApiHeader::class,
];
}
10 changes: 9 additions & 1 deletion app/Http/Middleware/ApiHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ class ApiHeader
public function handle($request, Closure $next)
{
if (config('api.header.accept') != $request->header('Accept')) {
return response()->json(['message' => 'Invalid Accept Header'], 400);
return response()->api(null, 'Invalid Accept Header', false, 400);
}

if (config('api.version') != $request->header('Version')) {
return response()->api(null, 'Missing API Version', false, 400);

if(!in_array($request->header('Version'), config('api.versions'))) {
return response()->api(null, 'Invalid API Version', false, 400);
}
}

return $next($request);
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"spatie/laravel-sluggable": "^2.1",
"thepinecode/i18n": "^0.2.0",
"tightenco/ziggy": "^0.6.6",
"tymon/jwt-auth": "^0.5.12",
"yajra/laravel-datatables": "^1.0"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 0126770

Please sign in to comment.