mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-23 12:15:23 +02:00
fix: rewrite and improve caching (#3594)
This commit is contained in:
parent
a786bbd4e0
commit
4b9f6f7e53
45 changed files with 993 additions and 1169 deletions
|
@ -1,18 +1,17 @@
|
|||
<?php
|
||||
|
||||
class HttpException extends \Exception
|
||||
{
|
||||
}
|
||||
|
||||
final class CloudFlareException extends HttpException
|
||||
{
|
||||
}
|
||||
|
||||
// https://github.com/nette/utils/blob/master/src/Utils/Json.php
|
||||
final class Json
|
||||
{
|
||||
public static function encode($value): string
|
||||
public static function encode($value, $pretty = true, bool $asciiSafe = false): string
|
||||
{
|
||||
$flags = JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||
$flags = JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES;
|
||||
if (!$asciiSafe) {
|
||||
$flags = $flags | JSON_UNESCAPED_UNICODE;
|
||||
}
|
||||
if ($pretty) {
|
||||
$flags = $flags | JSON_PRETTY_PRINT;
|
||||
}
|
||||
return \json_encode($value, $flags);
|
||||
}
|
||||
|
||||
|
@ -237,3 +236,13 @@ function create_random_string(int $bytes = 16): string
|
|||
{
|
||||
return bin2hex(openssl_random_pseudo_bytes($bytes));
|
||||
}
|
||||
|
||||
function returnClientError($message)
|
||||
{
|
||||
throw new \Exception($message, 400);
|
||||
}
|
||||
|
||||
function returnServerError($message)
|
||||
{
|
||||
throw new \Exception($message, 500);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue