Merge branch 'pr/hyperf/httpserver' of github.com:donjan-deng/hyperf into pr/hyperf/httpserver

This commit is contained in:
Donjan 2019-12-30 09:35:36 +08:00
commit e94dbdfbc1

View File

@ -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.
*