mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-08 21:14:40 +02:00
feat: token authentication (#3927)
This commit is contained in:
parent
d08d13f2c8
commit
e58c867a82
13 changed files with 95 additions and 138 deletions
14
lib/http.php
14
lib/http.php
|
@ -170,6 +170,7 @@ final class Request
|
|||
{
|
||||
private array $get;
|
||||
private array $server;
|
||||
private array $attributes;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
@ -180,6 +181,7 @@ final class Request
|
|||
$self = new self();
|
||||
$self->get = $_GET;
|
||||
$self->server = $_SERVER;
|
||||
$self->attributes = [];
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -200,6 +202,18 @@ final class Request
|
|||
return $this->server[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function withAttribute(string $name, $value = true): self
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->attributes[$name] = $value;
|
||||
return $clone;
|
||||
}
|
||||
|
||||
public function attribute(string $key, $default = null)
|
||||
{
|
||||
return $this->attributes[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->get;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue