Class RequestRateLimitAbstractInterceptor

java.lang.Object
com.imyeyu.spring.annotation.RequestRateLimitAbstractInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public abstract class RequestRateLimitAbstractInterceptor extends Object implements org.springframework.web.servlet.HandlerInterceptor
抽象访问频率限制,具体子类实现
Version:
2021-08-16 18:07
Author:
夜雨
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    beforeRun(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, String id, int cycle, int limit)
    接口访问前触发
    protected String
    buildId(org.springframework.web.method.HandlerMethod handlerMethod)
    构建接口标识
    boolean
    preHandle(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, Object handler)
    处理前

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor

    afterCompletion, postHandle
  • Constructor Details

    • RequestRateLimitAbstractInterceptor

      public RequestRateLimitAbstractInterceptor()
  • Method Details

    • buildId

      protected String buildId(org.springframework.web.method.HandlerMethod handlerMethod)
      构建接口标识
      Parameters:
      handlerMethod - 方法信息
      Returns:
      接口标识
    • preHandle

      public boolean preHandle(@NonNull jakarta.servlet.http.HttpServletRequest req, @NonNull jakarta.servlet.http.HttpServletResponse resp, @NonNull Object handler)
      处理前
      Specified by:
      preHandle in interface org.springframework.web.servlet.HandlerInterceptor
      Parameters:
      req - 请求
      resp - 返回
      handler - 处理方法
      Returns:
      true 为通过
    • beforeRun

      public abstract boolean beforeRun(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, String id, int cycle, int limit)
      接口访问前触发
      Parameters:
      req - 请求
      resp - 返回
      id - 方法
      cycle - 生命周期
      limit - 访问限制
      Returns:
      true 为通过