ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractHandler.php
Go to the documentation of this file.
1<?php
9namespace Slim\Handlers;
10
12
16abstract class AbstractHandler
17{
23 protected $knownContentTypes = [
24 'application/json',
25 'application/xml',
26 'text/xml',
27 'text/html',
28 ];
29
41 {
42 $acceptHeader = $request->getHeaderLine('Accept');
43 $selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes);
44
45 if (count($selectedContentTypes)) {
46 return current($selectedContentTypes);
47 }
48
49 // handle +json and +xml specially
50 if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) {
51 $mediaType = 'application/' . $matches[1];
52 if (in_array($mediaType, $this->knownContentTypes)) {
53 return $mediaType;
54 }
55 }
56
57 return 'text/html';
58 }
59}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
Abstract Slim application handler.
determineContentType(ServerRequestInterface $request)
Determine which content type we know about is wanted using Accept header.
Representation of an incoming, server-side HTTP request.
Slim Framework (https://slimframework.com)