mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
allow some endpoints to bypass microcaching
This commit is contained in:
parent
77b5a4e07c
commit
acdbc85c74
@ -9,6 +9,14 @@ use Jikan\Exception\BadResponseException;
|
||||
|
||||
class MicroCaching
|
||||
{
|
||||
private const NO_CACHING = [
|
||||
'RandomController@anime',
|
||||
'RandomController@manga',
|
||||
'RandomController@characters',
|
||||
'RandomController@people',
|
||||
'RandomController@users',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
@ -18,6 +26,12 @@ class MicroCaching
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$route = explode('\\', $request->route()[1]['uses']);
|
||||
$route = end($route);
|
||||
if (\in_array($route, self::NO_CACHING)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if ($request->header('auth') === env('APP_KEY')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user