Skip to content

Commit

Permalink
1.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
noear committed Sep 28, 2022
1 parent 917ea83 commit 97fcef2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions _solon_extend/solon.auth/src/test/java/demo1/DemoFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package demo1;

import org.noear.solon.annotation.Component;
import org.noear.solon.auth.AuthException;
import org.noear.solon.auth.AuthStatus;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.FilterChain;
import org.noear.solon.core.handle.Result;

/**
* @author noear 2022/9/28 created
*/
@Component
public class DemoFilter implements Filter {
@Override
public void doFilter(Context ctx, FilterChain chain) throws Throwable {
try {
chain.doFilter(ctx);
} catch (AuthException e) {
AuthStatus status = e.getStatus();
ctx.render(Result.failure(status.code, status.message));
}
}
}
24 changes: 24 additions & 0 deletions _solon_extend/solon.validation/src/test/java/demo1/DemoFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package demo1;

import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.FilterChain;
import org.noear.solon.core.handle.Result;
import org.noear.solon.validation.ValidatorException;


/**
* @author noear 2022/9/28 created
*/
@Component
public class DemoFilter implements Filter {
@Override
public void doFilter(Context ctx, FilterChain chain) throws Throwable {
try {
chain.doFilter(ctx);
} catch (ValidatorException e) {
ctx.render(Result.failure(e.getCode(), e.getMessage()));
}
}
}

0 comments on commit 97fcef2

Please sign in to comment.