public function BanMiddleware::handle in Drupal 8
Same name and namespace in other branches
- 9 core/modules/ban/src/BanMiddleware.php \Drupal\ban\BanMiddleware::handle()
File
- core/
modules/ ban/ src/ BanMiddleware.php, line 45
Class
- BanMiddleware
- Provides a HTTP middleware to implement IP based banning.
Namespace
Drupal\banCode
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
$ip = $request
->getClientIp();
if ($this->banIpManager
->isBanned($ip)) {
return new Response(new FormattableMarkup('@ip has been banned', [
'@ip' => $ip,
]), 403);
}
return $this->httpKernel
->handle($request, $type, $catch);
}