Java Code Examples for com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem#getPattern()

The following examples show how to use com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem#getPattern() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestContextApiMatcher.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
private Predicate<RequestContext> fromApiPathPredicate(/*@Valid*/ ApiPathPredicateItem item) {
    String pattern = item.getPattern();
    if (StringUtil.isBlank(pattern)) {
        return null;
    }
    switch (item.getMatchStrategy()) {
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_REGEX:
            return ZuulRouteMatchers.regexPath(pattern);
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX:
            return ZuulRouteMatchers.antPath(pattern);
        default:
            return ZuulRouteMatchers.exactPath(pattern);
    }
}
 
Example 2
Source File: WebExchangeApiMatcher.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
private Optional<Predicate<ServerWebExchange>> fromApiPathPredicate(/*@Valid*/ ApiPathPredicateItem item) {
    String pattern = item.getPattern();
    if (StringUtil.isBlank(pattern)) {
        return Optional.empty();
    }
    switch (item.getMatchStrategy()) {
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_REGEX:
            return Optional.of(RouteMatchers.regexPath(pattern));
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX:
            return Optional.of(RouteMatchers.antPath(pattern));
        default:
            return Optional.of(RouteMatchers.exactPath(pattern));
    }
}
 
Example 3
Source File: RequestContextApiMatcher.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
private Predicate<RequestContext> fromApiPathPredicate(/*@Valid*/ ApiPathPredicateItem item) {
    String pattern = item.getPattern();
    if (StringUtil.isBlank(pattern)) {
        return null;
    }
    switch (item.getMatchStrategy()) {
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_REGEX:
            return ZuulRouteMatchers.regexPath(pattern);
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX:
            return ZuulRouteMatchers.antPath(pattern);
        default:
            return ZuulRouteMatchers.exactPath(pattern);
    }
}
 
Example 4
Source File: WebExchangeApiMatcher.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
private Optional<Predicate<ServerWebExchange>> fromApiPathPredicate(/*@Valid*/ ApiPathPredicateItem item) {
    String pattern = item.getPattern();
    if (StringUtil.isBlank(pattern)) {
        return Optional.empty();
    }
    switch (item.getMatchStrategy()) {
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_REGEX:
            return Optional.of(RouteMatchers.regexPath(pattern));
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX:
            return Optional.of(RouteMatchers.antPath(pattern));
        default:
            return Optional.of(RouteMatchers.exactPath(pattern));
    }
}
 
Example 5
Source File: HttpRequestMessageApiMatcher.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
private Predicate<HttpRequestMessage> fromApiPathPredicate(/*@Valid*/ ApiPathPredicateItem item) {
    String pattern = item.getPattern();
    if (StringUtil.isBlank(pattern)) {
        return null;
    }
    switch (item.getMatchStrategy()) {
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_REGEX:
            return ZuulRouteMatchers.regexPath(pattern);
        case SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX:
            return ZuulRouteMatchers.antPath(pattern);
        default:
            return ZuulRouteMatchers.exactPath(pattern);
    }
}