spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

How to configure multiple microservice in route using java

Open manojsinghsaun opened this issue 2 years ago • 1 comments

I need add three services in route like given below but with java configuration. spring: cloud: gateway: mvc: routes: - id: service1 uri: http://localhost:8081/ predicates: - Path=/api/** - id: service2 uri: http://localhost:8082/ predicates: - Path=/api/** - id: service2 uri: http://localhost:8083/ predicates: - Path=/api/** - I can add one services in java like this class SimpleGateway { @Bean public RouterFunction<ServerResponse> getRoute() { return route().GET("/get", http("https://httpbin.org")); } }

but how can I add Multiple services in java? please can you add that in a document.

manojsinghsaun avatar Dec 26 '23 07:12 manojsinghsaun

	@Bean
	public RouteLocator getRouteLocator(RouteLocatorBuilder builder) {
		return builder.routes().route(r -> r.path("/t/**")
				.filters(f -> f.stripPrefix(1).filter(new TimeGatewayFilter())).uri(uri)).build();
	}

kimmking avatar Jan 14 '24 17:01 kimmking

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Mar 18 '24 21:03 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Mar 25 '24 21:03 spring-cloud-issues