org.springframework.cloud.gateway.support.NameUtils Java Examples

The following examples show how to use org.springframework.cloud.gateway.support.NameUtils. 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: SwaggerProvider.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    Set<String> routes = new HashSet<>();
    //取出Spring Cloud Gateway中的route
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    //结合application.yml中的路由配置,只获取有效的route节点
    gatewayProperties.getRoutes().stream().filter(
            routeDefinition -> (
                    routes.contains(routeDefinition.getId()) && swaggerAggProperties.isShow(routeDefinition.getId())
            )
    ).forEach(routeDefinition -> routeDefinition.getPredicates().stream()
            .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
            .forEach(predicateDefinition -> resources.add(
                swaggerResource(
                        routeDefinition.getId(),
                        predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", swaggerAggProperties.getApiDocsPath())
                    )
                )
            )
    );
    return resources;
}
 
Example #2
Source File: GatewaySwaggerProvider.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    List<String> routes = new ArrayList<>();
    //取出Spring Cloud Gateway中的route
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    //结合application.yml中的路由配置,只获取有效的route节点
    gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
            .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
                    .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
                    .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
                            predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
                                    .replace("/**", API_URI)))));
    return resources;
}
 
Example #3
Source File: FebsDocGatewayResourceConfigure.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    List<String> routes = new ArrayList<>();
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())).forEach(route -> route.getPredicates().stream()
            .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
            .forEach(predicateDefinition -> resources.add(swaggerResource(route.getId(),
                    predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
                            .replace("**", "v2/api-docs")))));

    return resources;
}
 
Example #4
Source File: SwaggerProvider.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    List<String> routes = new ArrayList<>();
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
            .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
                    .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
                    .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
                            predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
                                    .replace("/**", API_URI)))));
    return resources;
}
 
Example #5
Source File: SwaggerProviderConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    List<String> routes = new ArrayList<>();
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
            .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
                    .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
                    .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
                            predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
                                    .replace("/**", API_URI)))));
    return resources;
}
 
Example #6
Source File: SwaggerProviderConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
    List<SwaggerResource> resources = new ArrayList<>();
    List<String> routes = new ArrayList<>();
    routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
    gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
            .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
                    .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
                    .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
                            predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
                                    .replace("/**", API_URI)))));
    return resources;
}
 
Example #7
Source File: SwaggerProvider.java    From black-shop with Apache License 2.0 5 votes vote down vote up
@Override
public List<SwaggerResource> get() {
	List<SwaggerResource> resources = new ArrayList<>();
	List<String> routes = new ArrayList<>();
	routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
	gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())).forEach(route -> {
		route.getPredicates().stream()
				.filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
				.forEach(predicateDefinition -> resources.add(swaggerResource(route.getId(),
						predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
								.replace("**", "v2/api-docs"))));
	});

	return resources;
}
 
Example #8
Source File: PredicateDefinition.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
public PredicateDefinition(String text) {
	int eqIdx = text.indexOf('=');
	if (eqIdx <= 0) {
		throw new ValidationException("Unable to parse PredicateDefinition text '"
				+ text + "'" + ", must be of the form name=value");
	}
	setName(text.substring(0, eqIdx));

	String[] args = tokenizeToStringArray(text.substring(eqIdx + 1), ",");

	for (int i = 0; i < args.length; i++) {
		this.args.put(NameUtils.generateName(i), args[i]);
	}
}
 
Example #9
Source File: FilterDefinition.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
public FilterDefinition(String text) {
	int eqIdx = text.indexOf('=');
	if (eqIdx <= 0) {
		setName(text);
		return;
	}
	setName(text.substring(0, eqIdx));

	String[] args = tokenizeToStringArray(text.substring(eqIdx + 1), ",");

	for (int i = 0; i < args.length; i++) {
		this.args.put(NameUtils.generateName(i), args[i]);
	}
}
 
Example #10
Source File: RoutePredicateFactory.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
default String name() {
	return NameUtils.normalizeRoutePredicateName(getClass());
}
 
Example #11
Source File: GatewayFilterFactory.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
default String name() {
	// TODO: deal with proxys
	return NameUtils.normalizeFilterFactoryName(getClass());
}