新增 SaRouter.stop() 函数

This commit is contained in:
shengzhang
2021-06-03 23:30:16 +08:00
parent 4efb0568e5
commit c57a5cfc9d
18 changed files with 142 additions and 71 deletions

View File

@@ -0,0 +1,22 @@
package cn.dev33.satoken.exception;
/**
* 一个异常:代表停止路由匹配
*
* @author kong
*/
public class StopMatchException extends SaTokenException {
/**
* 序列化版本号
*/
private static final long serialVersionUID = 6806129545290130143L;
/**
* 构造
*/
public StopMatchException() {
super("stop match");
}
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.exception.StopMatchException;
import cn.dev33.satoken.fun.IsRunFunction;
import cn.dev33.satoken.fun.SaFunction;
@@ -13,7 +14,7 @@ import cn.dev33.satoken.fun.SaFunction;
* @author kong
*
*/
public class SaRouterUtil {
public class SaRouter {
// -------------------- 路由匹配相关 --------------------
@@ -123,7 +124,16 @@ public class SaRouterUtil {
boolean matchResult = isMatch(Arrays.asList(patterns), SaHolder.getRequest().getRequestPath());
return new IsRunFunction(matchResult);
}
// -------------------- 其它操作 --------------------
/**
* 停止匹配跳出函数 (在多个匹配链中一次性跳出Auth函数)
*/
public static void stop() {
throw new StopMatchException();
}