restlet 过滤器

filter代码如下 (具体需要过滤的信息需要更具需求完成):

public class GeneralFilter extends org.restlet.routing.Filter {
    
    public GeneralFilter(Context context) {
        super(context);
    }
    
    public GeneralFilter(Context context, Restlet next) {
        super(context,next);
    }

    protected void afterHandle(Request request, Response response) {
        super.afterHandle(request, response);
    }

    protected int beforeHandle(Request request, Response response) {
        return super.beforeHandle(request, response);
    }

    protected int doHandle(Request request, Response response) {
        return super.doHandle(request, response);
    }

}

调用方式(在Application的之类中调用)

public Restlet createInboundRoot() {
        Router router = new Router(getContext()); 
        //... ...
        
        GeneralFilter filter = new GeneralFilter(this.getContext(), router);
        return filter;
    }

 

扩展 : https://www.cnblogs.com/hi-gdl/p/11452713.html

posted on 2019-09-03 10:55  hi-gdl  阅读(336)  评论(0编辑  收藏  举报

导航