function 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) : Response {
  $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);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
