Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud Gateway RouteLocator Java Code Can not get with specific route id

I have tried to custom RouteLocator in Spring Cloud Gateway with Java Code. I can see all the list of routes that registered with endpoint /actuator/gateway/routes but when I was trying to get the specific route in given id it is 404 /actuator/gateway/routes/auth-server.

This is what I was trying to invoke /actuator/gateway/routes

[
    {
        "route_id": "auth-server",
        "route_object": {
            "predicate": "org.springframework.cloud.gateway.support.ServerWebExchangeUtils$$Lambda$264/896945135@4e9d7b14"
        },
        "order": 0
    },
    {
        "route_id": "song",
        "route_object": {
            "predicate": "org.springframework.cloud.gateway.support.ServerWebExchangeUtils$$Lambda$264/896945135@7d49ff95"
        },
        "order": 0
    }
]

The one with specific route /actuator/gateway/routes/auth-server

http://localhost:8080/actuator/gateway/routes/auth-server

I got the result status code 404 not found.

This is java custom route configuration:

@Configuration
public class RouteConfiguration {


    @Bean
        RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {

        return routeLocatorBuilder.routes()
                .route("auth-server", predicateSpec -> predicateSpec.path("/uaa/**").uri("lb://auth-service"))
                .route("song", predicateSpec -> predicateSpec.path("/song/**").uri("lb/song-service"))
                .build();
    }

}

It should be given with auth-server route.

like image 606
soyphea Avatar asked Mar 18 '26 12:03

soyphea


1 Answers

@soyphea That's a known issue, but I couldn't find the ticket back on GitHub. Can you create a bug report for this just to be sure: https://github.com/spring-cloud/spring-cloud-gateway/issues/new? Thanks for your great question!

like image 140
TYsewyn Avatar answered Mar 20 '26 00:03

TYsewyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!