content: package com.gupaoedu.book.springcloud.sentinel.springcloudsentinelsample;
  
  import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
  import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
  import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
  import com.alibaba.csp.sentinel.slots.block.BlockException;
  import org.springframework.stereotype.Service;
  
  import javax.annotation.PostConstruct;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.IOException;
  import java.nio.charset.StandardCharsets;
  
  /**
   * 咕泡学院，只为更好的你
   * 咕泡学院-Mic: 2227324689
   * http://www.gupaoedu.com
   **/
  //@Service
  public class CustomUrlBlockHandler implements UrlBlockHandler{
      @Override
      public void blocked(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws IOException {
          httpServletResponse.setHeader("Content-Type", "application/json;charset=UTF-8");
          String message = "{\"code\":999,\"msg\":\"访问人数过多\"}";
          httpServletResponse.getWriter().write(message);
      }
  }
  
  