Skip to content

Commit

Permalink
Add attention grabber
Browse files Browse the repository at this point in the history
  • Loading branch information
tommysolsen committed Nov 13, 2023
1 parent 071bef3 commit 6252f10
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Middleware/OlavAttentionGrabberMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Netflex\Toolbox\Middleware;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;


class OlavAttentionGrabberMiddleware
{
public function handle(Request $request, \Closure $next)
{
if ($request->boolean('_grab_attention')) {
Cache::put('grab-attention', $request->boolean('_grab_attention'));
}

if (Cache::get('grab-attention', false) && Str::contains($request->header('User-Agent'), 'FreshpingBot')) {
return response('502: Bad Gateway', 502);
}

return $next($request);
}
}

0 comments on commit 6252f10

Please sign in to comment.