All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.easyopen.interceptor.ApiInterceptor Maven / Gradle / Ivy

Go to download

easyopen mini版,保留基本签名校验,文档功能。https://gitee.com/durcframework/easyopen

There is a newer version: 1.0.4
Show newest version
package com.gitee.easyopen.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gitee.easyopen.ApiMeta;

/**
 * 拦截器,原理同springmvc拦截器
 * @author tanghc
 *
 */
public interface ApiInterceptor {
    /**
     * 预处理回调方法,在方法调用前执行。返回false不继续向下执行,此时可使用response返回错误信息
     * @param request
     * @param response
     * @param apiMeta 接口元数据
     * @param argu 方法参数
     * @return 返回false不继续向下执行,此时可使用response返回错误信息
     * @throws Throwable
     */
    boolean preHandle(HttpServletRequest request, HttpServletResponse response, ApiMeta apiMeta, Object argu)
            throws Throwable;

    /**
     * 接口方法执行完后调用此方法。
     * @param request
     * @param response
     * @param apiMeta 接口元数据
     * @param argu 参数
     * @param result 方法返回结果
     * @throws Throwable
     */
    void postHandle(HttpServletRequest request, HttpServletResponse response, ApiMeta apiMeta, Object argu,
            Object result) throws Throwable;

    /**
     * 结果包装完成后执行
     * @param request
     * @param response
     * @param apiMeta 接口元数据
     * @param argu 参数
     * @param result 最终结果,被包装过
     * @param e 
     * @throws Throwable
     */
    void afterCompletion(HttpServletRequest request, HttpServletResponse response, ApiMeta apiMeta, Object argu,
            Object result, Throwable e) throws Throwable;

    /**
     * 匹配拦截器,返回true则执行该拦截器,否则忽略该拦截器
     * @param apiMeta 接口信息
     * @return 返回true,使用该拦截器,返回false跳过不使用。
     */
    boolean match(ApiMeta apiMeta);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy