mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
29 lines
752 B
PHP
29 lines
752 B
PHP
<?php
|
|
|
|
namespace App\Macros;
|
|
|
|
use App\Support\CachedData;
|
|
use App\Support\CacheOptions;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* @mixin Response
|
|
*/
|
|
final class ResponseJikanCacheFlags
|
|
{
|
|
public function __invoke(): \Closure
|
|
{
|
|
return function (string $cacheKey, CachedData $scraperResults) {
|
|
/**
|
|
* @var Response $this
|
|
*/
|
|
return $this
|
|
->header("X-Request-Fingerprint", $cacheKey)
|
|
->setTtl(app(CacheOptions::class)->ttl())
|
|
->setExpires(Carbon::createFromTimestamp($scraperResults->expiry()))
|
|
->setLastModified(Carbon::createFromTimestamp($scraperResults->lastModified() ?? 0));
|
|
};
|
|
}
|
|
}
|