mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 12:47:55 +08:00
Merge branch 'pr/hyperf/httpserver' of github.com:donjan-deng/hyperf into pr/hyperf/httpserver
This commit is contained in:
commit
e94dbdfbc1
@ -59,6 +59,20 @@ class Request implements RequestInterface
|
||||
}
|
||||
return data_get($this->getQueryParams(), $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the data from route parameters.
|
||||
*
|
||||
* @param mixed $default
|
||||
*/
|
||||
public function route(string $key, $default = null)
|
||||
{
|
||||
$route = $this->getAttribute(Dispatched::class);
|
||||
if (is_null($route)) {
|
||||
return $default;
|
||||
}
|
||||
return array_key_exists($key, $route->params) ? $route->params[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the data from parsed body, if $key is null, will return all parsed body.
|
||||
@ -157,20 +171,6 @@ class Request implements RequestInterface
|
||||
return $this->getHeaderLine($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the data from route parameters.
|
||||
*
|
||||
* @param mixed $default
|
||||
*/
|
||||
public function route(string $key, $default = null)
|
||||
{
|
||||
$route = $this->getAttribute(Dispatched::class);
|
||||
if (is_null($route)) {
|
||||
return $default;
|
||||
}
|
||||
return array_key_exists($key, $route->params) ? $route->params[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current path info for the request.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user