mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-30 14:49:53 +02:00
refactor: extract frontpage to template (#3130)
Also introduce usage of Response object
This commit is contained in:
parent
fe59cbabc9
commit
2ef98b299f
12 changed files with 147 additions and 225 deletions
|
@ -44,6 +44,38 @@ final class Response
|
|||
'504' => 'Gateway Timeout',
|
||||
'505' => 'HTTP Version Not Supported'
|
||||
];
|
||||
private string $body;
|
||||
private int $code;
|
||||
private array $headers;
|
||||
|
||||
public function __construct(
|
||||
string $body = '',
|
||||
int $code = 200,
|
||||
array $headers = []
|
||||
) {
|
||||
$this->body = $body;
|
||||
$this->code = $code;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function send(): void
|
||||
{
|
||||
http_response_code($this->code);
|
||||
foreach ($this->headers as $name => $value) {
|
||||
header(sprintf('%s: %s', $name, $value));
|
||||
}
|
||||
print $this->body;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue