在SLIM 3中,是否有方法将全局响应的内容类型设置为"application/json"?
我尝试了以下不起作用的东西:
$app->contentType('application/json');
$app->response->headers->set('Content-Type', 'application/json');
中间件:
$app->add(function ($request, $response, $next) {
return $response->withHeader('Content-Type', 'application/json');
});