Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/Router.php
This commit is contained in:
xl
2023-07-06 16:01:36 +08:00
4 changed files with 29 additions and 3 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ class ConstrictResponse extends Message implements ResponseInterface
* @param int $statusCode * @param int $statusCode
* @return $this * @return $this
*/ */
public function html(string $content, int $statusCode = 200): static public function html(string $content = '', int $statusCode = 200): static
{ {
$this->getBody()->write($content); $this->getBody()->write($content);
return $this->withContentType(ContentType::HTML)->withStatus($statusCode); return $this->withContentType(ContentType::HTML)->withStatus($statusCode);
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Kiri\Router;
use Kiri\Router\Annotate\AutoController;
use Kiri\Router\Base\Controller;
use Psr\Http\Message\ResponseInterface;
#[AutoController]
class OptionsController extends Controller
{
/**
* @return ResponseInterface
*/
public function index(): ResponseInterface
{
return $this->response->withHeaders(['Access-Control-Allow-Headers' => '*',
'Access-Control-Request-Method' => '*',
'Access-Control-Allow-Origin' => '*'
])->html();
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ class Response implements ResponseInterface
* @param int $statusCode * @param int $statusCode
* @return ResponseInterface * @return ResponseInterface
*/ */
public function html(string $content, int $statusCode = 200): ResponseInterface public function html(string $content = '', int $statusCode = 200): ResponseInterface
{ {
return $this->__call__(__FUNCTION__, $content, $statusCode); return $this->__call__(__FUNCTION__, $content, $statusCode);
} }
+1 -1
View File
@@ -171,7 +171,7 @@ class Router
/** /**
* @throws * @throws Exception
*/ */
public function scan_build_route(): void public function scan_build_route(): void
{ {