Search in sources :

Example 16 with ApiDefinition

use of com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition in project novel-cloud by 201206030.

the class GatewayConfiguration method initCustomizedApis.

private void initCustomizedApis() {
    Set<ApiDefinition> definitions = new HashSet<>();
    ApiDefinition api1 = new ApiDefinition("customized_api").setPredicateItems(new HashSet<ApiPredicateItem>() {

        {
            add(new ApiPathPredicateItem().setPattern("/api/**").setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
        }
    });
    ApiDefinition api2 = new ApiDefinition("book_content_api").setPredicateItems(new HashSet<ApiPredicateItem>() {

        {
            add(new ApiPathPredicateItem().setPattern("/api/book/queryBookContent**").setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
        }
    });
    definitions.add(api1);
    definitions.add(api2);
    GatewayApiDefinitionManager.loadApiDefinitions(definitions);
}
Also used : ApiDefinition(com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition) ApiPathPredicateItem(com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem) ApiPredicateItem(com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem)

Aggregations

ApiDefinition (com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition)16 ApiPathPredicateItem (com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem)13 ApiPredicateItem (com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem)13 HashSet (java.util.HashSet)6 LinkedHashSet (java.util.LinkedHashSet)5 GatewayFlowRule (com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule)2 DegradeRule (com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule)2 WebExchangeApiMatcher (com.alibaba.csp.sentinel.adapter.gateway.sc.api.matcher.WebExchangeApiMatcher)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 Listener (com.alibaba.nacos.api.config.listener.Listener)1 DoorGoodConfig (com.hummer.doorgod.service.domain.configuration.DoorGoodConfig)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Test (org.junit.Test)1 RequestPath (org.springframework.http.server.RequestPath)1 ServerHttpRequest (org.springframework.http.server.reactive.ServerHttpRequest)1 ServerWebExchange (org.springframework.web.server.ServerWebExchange)1