如何在Zend Expressive 2中使用HtmlResponse更改或添加标题?
class NotModifiedMiddleware implements ServerMiddlewareInterface
{
/**
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
* @param ServerRequestInterface $request
* @param DelegateInterface $delegate
*
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
}
}
这很简单。
您只需要让委托处理请求并获得响应,例如:
return new HtmlResponse($data, 200, ['Content-Type' => 'application/x-yaml']);