Closed gabriel403 closed 8 years ago
$this->registerMediaTypeParser('application/json', function ($input) { return json_decode($input, true); });
$acceptHeaders = []; if (count($request->getHeader('ACCEPT')) > 0) { foreach ($request->getHeader('ACCEPT') as $header) { $acceptHeaders = array_merge($acceptHeaders, explode(', ', $header)); } } if (in_array('application/json', $acceptHeaders)) { $response = $response->withJson($response->getBody()); } return $response;
Or possibly $request->getMediaType() rather than accept headers?
$request->getMediaType()
First part now covered in slim core slimphp/Slim#1489