Search in sources :

Example 1 with MappingResult

use of io.fabric8.gateway.support.MappingResult in project fabric8 by jboss-fuse.

the class MappingRuleResolver method findMappingRule.

public MappingResult findMappingRule(String requestURI) {
    String[] paths = Paths.splitPaths(requestURI);
    MappingResult answer = null;
    // TODO we could build a path based tree to do more efficient matching?
    for (HttpProxyRule mappingRule : mappingRules.getMappingRules().values()) {
        answer = mappingRule.matches(paths);
        if (answer != null) {
            break;
        }
    }
    return answer;
}
Also used : HttpProxyRule(io.fabric8.gateway.model.HttpProxyRule)

Example 2 with MappingResult

use of io.fabric8.gateway.support.MappingResult in project fabric8 by jboss-fuse.

the class HttpMappingRuleResolver method findMappingRule.

public HttpMappingResult findMappingRule(HttpServletRequest request, HttpServletResponse response) {
    String requestURI = request.getRequestURI();
    String contextPath = request.getContextPath();
    MappingResult answer = null;
    if (contextPath != null && contextPath.length() > 0 && !contextPath.equals("/")) {
        String requestWithoutContextPath = requestURI.substring(contextPath.length());
        answer = resolver.findMappingRule(requestWithoutContextPath);
    }
    if (answer == null) {
        // lets try the full request URI with the context path to see if that maps
        answer = resolver.findMappingRule(requestURI);
    }
    return answer != null ? new HttpMappingResult(answer) : null;
}
Also used : MappingResult(io.fabric8.gateway.support.MappingResult)

Aggregations

HttpProxyRule (io.fabric8.gateway.model.HttpProxyRule)1 MappingResult (io.fabric8.gateway.support.MappingResult)1