UNPKG

node-web-mvc

Version:
55 lines (54 loc) 1.73 kB
/** * @module InterceptorRegistration * @description 拦截器登记信息 */ import HandlerInterceptor from './HandlerInterceptor'; import MappedInterceptor from './MappedInterceptor'; import PathMatcher from '../util/PathMatcher'; export default class InterceptorRegistration { readonly interceptor: HandlerInterceptor; readonly includePatterns: string[]; readonly excludePatterns: string[]; private pathMatcher; /** * 在注册表中的顺序 */ private order; /** * 构造一个拦截器登记实例 * @param interceptor 当前登记的拦截器 */ constructor(interceptor: HandlerInterceptor); /** * 设置当前登记信息优先级 * @param order */ setOrder(order: number): this; /** * 获取顺序值 */ getOrder(): number; /** * 设置当前路径匹配器 * @param patterns */ setPathMatcher(pathMatcher: PathMatcher): void; /** * 添加拦截器包含规则。 * 注意:(【包含项规则】 优先级会低于 【排除项规则】) * 通过url匹配规则,来设置当前拦截器是否执行。 */ addPathPatterns(...patterns: Array<string>): this; /** * 添加拦截器排除规则。 * 注意:(【排除项规则】 优先级高于 【包含规则】) * 通过url排除规则,来设置当前拦截器,在命中排除规则后,将不会执行。 * @param patterns */ excludePathPatterns(...patterns: Array<string>): this; /** * 获取当前登记的拦截器实例, * 会根据配置的信息,来构造对应的实例。 */ getInterceptor(): HandlerInterceptor | MappedInterceptor; }