Skip to content

Commit

Permalink
Added response content-type header for swagger server. (#6360)
Browse files Browse the repository at this point in the history

Co-authored-by: 李铭昕 <[email protected]>
  • Loading branch information
xuanyanwow and limingxinleo authored Dec 6, 2023
1 parent afbc76d commit cfc1647
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public function onRequest($request, $response): void
$path = $psr7Request->getUri()->getPath();
if ($path === $this->config['url']) {
$stream = new Stream($this->getHtml());
$contentType = 'text/html;charset=utf-8';
} else {
$stream = new Stream($this->getMetadata($path));
$contentType = 'application/json;charset=utf-8';
}

$psrResponse = (new Response())->withBody($stream);
$psrResponse = (new Response())->setBody($stream)->setHeader('content-type', $contentType);

$this->emitter->emit($psrResponse, $response);
}
Expand Down

0 comments on commit cfc1647

Please sign in to comment.