/**
 *  Copyright 2015 Peak Tai,台俊峰(taijunfeng_it@sina.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.jfinal.rest;

import com.jfinal.handler.Handler;
import com.jfinal.log.Logger;
import com.jfinal.render.RenderFactory;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * restful handler
 * Created by peak on 2015/1/22.
 */
public class RestHandler extends Handler {
    /**
     * 访问路径
     */
    private RestRoutes routes = null;
    private final Logger log = Logger.getLogger(RestHandler.class);

    public RestHandler(RestRoutes routes) {
        this.routes = routes;
    }

    @Override
    public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
        String visitPath = routes.getVisitPath();
        if (!target.startsWith(visitPath)) {
            nextHandler.handle(target, request, response, isHandled);
            return;
        }
        isHandled[0] = true;
        String newTarget = routes.match(target, request);
        if (newTarget == null) {
            if (log.isWarnEnabled()) {
                String qs = request.getQueryString();
                log.warn("404 Action Not Found: " + (qs == null ? target : target + "?" + qs));
            }
            RenderFactory.me().getErrorRender(404).setContext(request, response).render();
            return;
        }
        nextHandler.handle(newTarget, request, response, isHandled);
    }
}

@@ -1,15 +1,14 @@
 /**%0A *
- 
  Copyrig
@@ -54,20 +54,24 @@
 .com)%0A *
+ %3Cp/%3E
 %0A *
- 
  License
@@ -129,17 +129,16 @@
 se%22);%0A *
- 
  you may
@@ -197,17 +197,16 @@
 ense.%0A *
- 
  You may
@@ -244,16 +244,16 @@
 t%0A *
-%0A *     
+ %3Cp/%3E%0A *
  htt
@@ -294,20 +294,24 @@
 E-2.0%0A *
+ %3Cp/%3E
 %0A *
- 
  Unless 
@@ -373,17 +373,16 @@
 tware%0A *
- 
  distrib
@@ -442,17 +442,16 @@
 ASIS,%0A *
- 
  WITHOUT
@@ -518,17 +518,16 @@
 lied.%0A *
- 
  See the
@@ -589,17 +589,16 @@
 s and%0A *
- 
  limitat
@@ -1393,16 +1393,22 @@
 isitPath
+ + %22/%22
 )) %7B%0A   

修复设置多个版本的访问路径，路径开头部分相同解析不正解的bug