Skip to content
/ au Public

Au is a filter framework. It is an extension based on servlet-filter.

License

Notifications You must be signed in to change notification settings

lazycece/au

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Au

Maven Central License GitHub release

中文

Au is a filter framework. It is an extension based on servlet-filter. It provides pre-filtering and post-filtering of interceptor behavior. It also provides multiple reads of requests and a wrapper for response.

Architecture

The architecture of Au as follows:

architecture_diagram

Environment

Au environment dependency as follow:

Au Java servlet-api
1.x 1.8+ javax.servlet-api:>=4.0.0
2.x 1.8+ jakarta.servlet-api:>=5.0.0
3.x 17+ jakarta.servlet-api:>=5.0.0

Quick Start

Complete example can view au-example

Maven dependency

<dependency>
  <groupId>com.lazycece.au</groupId>
  <artifactId>au-core</artifactId>
  <version>${au.core.version}</version>
</dependency>

Filter

Defining filter,and implement the AuFilter.

public class SimpleAuFilter implements AuFilter {

    @Override
    public String name() {
        return "simple-filter";
    }

    @Override
    public boolean preHandle() throws Exception {
        // pre handle
        return true;
    }

    @Override
    public void postHandle() throws Exception {
        // post-handle
    }
}

Injecting AuFilter,and you can also set related policies for filters.

    AuManager auManager = AuManager.getInstance();
    auManager.addAuFilter(SimpleAuFilter.class)
            .excludePatterns("/a/b")
            .includePatterns("/**")
            .order(1);
    auManager.setWrapper(true);

Enable Au

Injecting AuServletFilter into Servlet, as follow(jetty):

    ServletContextHandler contextHandler = new ServletContextHandler();
    contextHandler.setContextPath("/au");
    server.setHandler(contextHandler);
    contextHandler.addServlet(ExampleServlet.class, "/*");
    contextHandler.addFilter(AuServletFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

License

Apache-2.0