本文整理汇总了Java中org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute方法的典型用法代码示例。如果您正苦于以下问题:Java ZuulProperties.ZuulRoute方法的具体用法?Java ZuulProperties.ZuulRoute怎么用?Java ZuulProperties.ZuulRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cloud.netflix.zuul.filters.ZuulProperties
的用法示例。
在下文中一共展示了ZuulProperties.ZuulRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: routeStore
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@ConditionalOnMissingBean(RouteStore.class)
@Bean
public RouteStore routeStore() {
return new RouteStore() {
@Override
public List<ZuulProperties.ZuulRoute> getAllRoutes() {
return Collections.emptyList();
}
@Override
public void onRoutesChange(Consumer<List<ZuulProperties.ZuulRoute>> handleFunction) {
handleFunction.accept(getAllRoutes());
}
@Override
public List<ServiceRoute> getAllServiceRoutes() {
return Collections.emptyList();
}
};
}
示例2: shouldReportDownState
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Test
public void shouldReportDownState() {
// given
final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
zuulProperties.getRoutes().put(route.getId(), route);
// when
final Health health = zuulRouteHealthIndicator.health();
// then
assertNotNull(health);
assertEquals(Status.DOWN, health.getStatus());
assertNull(health.getDetails().get("available"));
assertFalse(((Collection) health.getDetails().get("unavailable")).isEmpty());
}
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:17,代码来源:ZuulRouteHealthIndicatorTest.java
示例3: shouldReportUpState
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Test
public void shouldReportUpState() {
// given
final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
zuulProperties.getRoutes().put(route.getId(), route);
final List<ServiceInstance> services = new ArrayList<>();
services.add(mock(ServiceInstance.class));
when(discoveryClient.getInstances("proxied-service")).thenReturn(services);
// when
final Health health = zuulRouteHealthIndicator.health();
// then
assertNotNull(health);
assertEquals(Status.UP, health.getStatus());
assertFalse(((Collection) health.getDetails().get("available")).isEmpty());
assertNull(health.getDetails().get("unavailable"));
}
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:21,代码来源:ZuulRouteHealthIndicatorTest.java
示例4: locateRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulProperties.ZuulRoute> locateRoutes() {
LinkedHashMap<String, ZuulProperties.ZuulRoute> routeMap = super.locateRoutes();
routeStore.getAllRoutes().forEach(route -> routeMap.put(route.getPath(), route));
return routeMap;
}
示例5: locateRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulRoute> locateRoutes() {
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
routesMap.putAll(super.locateRoutes());
for (ZuulProperties.ZuulRoute route : findAll()) {
routesMap.put(route.getPath(), route);
}
return routesMap;
}
示例6: findAll
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
private List<ZuulProperties.ZuulRoute> findAll() {
Set<ZuulRouteDto> routers = Sets.newHashSet();
if (!hasLoaded) {
routers.addAll(store.loadAllRoute());
hasLoaded = true;
} else {
routers.addAll(store.loadTop10Route());
}
routesCache.addAll(routers);
return Lists.transform(Lists.newArrayList(routesCache),
new Function<ZuulRouteDto, ZuulProperties.ZuulRoute>() {
@Override
public ZuulRoute apply(ZuulRouteDto input) {
String id = input.getRouteId();
String path = input.getRoutePath();
String service_id = input.getServiceId();
String url = input.getRouteUrl();
boolean strip_prefix = input.getStripPrefix() != null ? input.getStripPrefix() : true;
Boolean retryable = input.getRetryAble();
String sensitiveHeader = input.getSensitiveHeaders();
String[] sensitiveHeaders = null;
if (sensitiveHeader != null) {
sensitiveHeaders = StringUtils.split(sensitiveHeader, ",");
} else {
sensitiveHeaders = new String[] {};
}
return new ZuulRoute(id, path, service_id, url, strip_prefix, retryable,
new HashSet<String>(Arrays.asList(sensitiveHeaders)));
}
});
}
示例7: getRouteHost
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Override
public String getRouteHost(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
ZuulProperties.ZuulRoute zuulRoute = zuulProperties.getRoutes().get(wsBrokerage.getId());
if (zuulRoute == null || StringUtils.isEmpty(zuulRoute.getServiceId())) return null;
List<ServiceInstance> instances = discoveryClient.getInstances(zuulRoute.getServiceId());
ServiceInstance serviceInstance = instances.get(0);
return serviceInstance.getUri().toString();
}
示例8: findAll
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<ZuulProperties.ZuulRoute> findAll() {
final Select query = QueryBuilder.select().from(keyspace, table);
return cassandraOperations.query(query, ZUUL_ROUTE_MAPPER);
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:10,代码来源:CassandraZuulRouteStore.java
示例9: mapRow
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ZuulProperties.ZuulRoute mapRow(Row row, int rowNum) throws DriverException {
return new ZuulProperties.ZuulRoute(
row.getString("id"),
row.getString("path"),
row.getString("service_id"),
row.getString("url"),
row.getBool("strip_prefix"),
row.getBool("retryable")
);
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:16,代码来源:CassandraZuulRouteStore.java
示例10: shouldRetrieveEmptyRouteList
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Test
public void shouldRetrieveEmptyRouteList() {
// given
cassandraTemplate.truncate("zuul_routes");
// when
final List<ZuulProperties.ZuulRoute> routes = instance.findAll();
// then
assertTrue(routes.isEmpty());
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:13,代码来源:CassandraZuulRouteStoreTest.java
示例11: shouldRetrieveConfiguredRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
@Test
public void shouldRetrieveConfiguredRoutes() {
// when
final List<ZuulProperties.ZuulRoute> routes = instance.findAll();
// then
assertFalse(routes.isEmpty());
assertEquals(2, routes.size());
final Map<String, ZuulProperties.ZuulRoute> routeMap = asMap(routes);
assertEquals("resource", routeMap.get("resource").getId());
assertEquals("/api/**", routeMap.get("resource").getPath());
assertEquals("rest-service", routeMap.get("resource").getServiceId());
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:15,代码来源:CassandraZuulRouteStoreTest.java
示例12: asMap
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
private Map<String, ZuulProperties.ZuulRoute> asMap(List<ZuulProperties.ZuulRoute> routes) {
final Map<String, ZuulProperties.ZuulRoute> map = new HashMap<String, ZuulProperties.ZuulRoute>();
for(ZuulProperties.ZuulRoute route : routes) {
map.put(route.getId(), route);
}
return map;
}
开发者ID:jmnarloch,项目名称:zuul-route-cassandra-spring-cloud-starter,代码行数:8,代码来源:CassandraZuulRouteStoreTest.java
示例13: setRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setRoutes(Map<String, ZuulProperties.ZuulRoute> routes) {
final Trie<ZuulRouteEntry> trie = createTrie();
for (Map.Entry<String, ZuulProperties.ZuulRoute> route : routes.entrySet()) {
trie.put(
path(route.getKey()),
new ZuulRouteEntry(route.getKey(), route.getValue(), isWildcard(route.getKey()))
);
}
this.trie.lazySet(trie);
}
示例14: getMatchingRoute
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ZuulProperties.ZuulRoute getMatchingRoute(String path) {
final ZuulRouteEntry matching = trie.get().prefix(path);
if (matching == null
|| !matching.isWildcard() && !matchesExact(path, matching.getPath())) {
return null;
} else {
return matching.getRoute();
}
}
示例15: toProxyRouteSpec
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入方法依赖的package包/类
/**
* Creates a {@link org.springframework.cloud.netflix.zuul.filters.ProxyRouteLocator.ProxyRouteSpec} out of
* {@link org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute}.
*
* @param route the zuul route
* @return the route spec
*/
private ProxyRouteSpec toProxyRouteSpec(final String path, final ZuulProperties.ZuulRoute route) {
if(route == null) {
return null;
}
String targetPath = getRequestPath(path);
String prefix = properties.getPrefix();
final Boolean retryable = isRetryable(route);
if (properties.isStripPrefix() && targetPath.startsWith(prefix)) {
targetPath = path.substring(prefix.length());
}
if (route.isStripPrefix()) {
int index = route.getPath().indexOf("*") - 1;
if (index > 0) {
String routePrefix = route.getPath().substring(0, index);
targetPath = targetPath.replaceFirst(routePrefix, "");
prefix = prefix + routePrefix;
}
}
return new ProxyRouteSpec(
route.getId(),
targetPath,
route.getLocation(),
prefix,
retryable
);
}
开发者ID:jmnarloch,项目名称:zuul-trie-matcher-spring-cloud-starter,代码行数:38,代码来源:MatcherProxyRouteLocator.java