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

The following examples show how to use org.springframework.cloud.gateway.support.NameUtils. These examples are extracted from open source projects. 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 Project: microservices-platform   Source File: SwaggerProvider.java    License: 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
@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
@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 Project: sophia_scaffolding   Source File: SwaggerProvider.java    License: 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 Project: sophia_scaffolding   Source File: SwaggerProviderConfig.java    License: 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 Project: sophia_scaffolding   Source File: SwaggerProviderConfig.java    License: 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 Project: black-shop   Source File: SwaggerProvider.java    License: 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 Project: spring-cloud-gateway   Source File: PredicateDefinition.java    License: 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 Project: spring-cloud-gateway   Source File: FilterDefinition.java    License: 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
default String name() {
	return NameUtils.normalizeRoutePredicateName(getClass());
}
 
Example 11
Source Project: spring-cloud-gateway   Source File: GatewayFilterFactory.java    License: Apache License 2.0 4 votes vote down vote up
default String name() {
	// TODO: deal with proxys
	return NameUtils.normalizeFilterFactoryName(getClass());
}