This commit is contained in:
as2252258@163.com
2021-08-06 00:50:25 +08:00
parent 7e84d06c57
commit d8cec79b3e
4 changed files with 13 additions and 37 deletions
+1 -12
View File
@@ -13,7 +13,7 @@ namespace HttpServer\Http;
* Class HttpHeaders
* @package Snowflake\Snowflake\Http
*/
class HttpHeaders
trait HttpHeaders
{
private array $_headers = [];
@@ -46,17 +46,6 @@ class HttpHeaders
}
/**
* @param $name
* @param null $default
* @return mixed
*/
public function get($name, $default = null): mixed
{
return $this->_headers[$name] ?? $default;
}
/**
* @return string
*/
+3 -12
View File
@@ -21,7 +21,7 @@ use Snowflake\Snowflake;
* Class HttpParams
* @package Snowflake\Snowflake\Http
*/
class HttpParams
trait HttpParams
{
/** @var array|null */
@@ -109,7 +109,7 @@ class HttpParams
*/
private function page(): int
{
return (int)$this->get('page', 1);
return (int)$this->query('page', 1);
}
@@ -129,19 +129,10 @@ class HttpParams
*/
public function size(): int
{
return (int)$this->get('size', 20);
return (int)$this->query('size', 20);
}
/**
* @param $name
* @param null $defaultValue
* @return mixed
*/
public function get($name, $defaultValue = null): mixed
{
return $this->_gets[$name] ?? $defaultValue;
}
/**
* @param $name
+3 -5
View File
@@ -33,14 +33,12 @@ defined('REQUEST_FAIL') or define('REQUEST_FAIL', 500);
class Request extends HttpService implements RequestInterface
{
use HttpHeaders, HttpParams;
public int $fd = 0;
/**
* @var HttpParams|null
*/
#[Inject(HttpParams::class)]
public ?HttpParams $params = null;
/**