Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function handle($request, Closure $next) |
||
15 | { |
||
16 | $supportedMediaTypes = resolve(Sarala::class)->getSupportedMediaTypes(); |
||
17 | |||
18 | if (! in_array($request->header('Content-Type'), $supportedMediaTypes)) { |
||
19 | throw new UnsupportedMediaTypeHttpException(); |
||
20 | } |
||
21 | |||
22 | if (! $request->accepts($supportedMediaTypes)) { |
||
23 | throw new NotAcceptableMediaTypeHttpException(); |
||
24 | } |
||
25 | |||
26 | $response = $next($request); |
||
27 | |||
28 | $response->header('Content-Type', $request->header('Accept')); |
||
29 | |||
30 | return $response; |
||
31 | } |
||
32 | } |
||
33 |