This commit is contained in:
2024-07-29 22:06:57 +02:00
parent 5ce2215e44
commit 6a62ae58fc
22 changed files with 670 additions and 7 deletions
+19
View File
@@ -5,22 +5,41 @@ namespace Khofmann\Request;
use Pecee\Http\Request as PRequest;
use Pecee\SimpleRouter\SimpleRouter;
/**
* Facade for Request access (wraps SimpleRouter)
*/
class Request
{
/**
* Private since facade.
*/
private function __construct()
{
}
/**
* Get current request
*/
public static function request(): PRequest
{
return SimpleRouter::request();
}
/**
* Get header value from current request
*
* @param string $name Field name
* @param mixed $defaultValue Default value if header field was null
* @param bool $tryParse When enabled the method will try to find the header from both from client (http) and server-side variants, if the header is not found.
*/
public static function header(string $name, $defaultValue = null, bool $tryParse = true): ?string
{
return Request::request()->getHeader($name, $defaultValue, $tryParse);
}
/**
* Get authentication header field
*/
public static function token()
{
return Request::header("token");