These are chat archives for spring-cloud/spring-cloud

25th
Mar 2019
CH4:D
@chad_d_stud_twitter
Mar 25 09:48
i've followed this tutorial and got it working: https://spring.io/guides/gs/gateway/
However, once I change the url to my local spring rest api (localhost:8081/actuator/info) it returns 404. The actuator works but why is it not working from the gateway?
Chris Overgaauw
@chrisovergaauw
Mar 25 09:51
what does your new uri look like exactly?
nothing fancy
also tried deploying it to a remote server with no luck
Chris Overgaauw
@chrisovergaauw
Mar 25 09:54
you tried to edit this part I assume?
@Bean
public RouteLocator myRoutes(RouteLocatorBuilder builder) {
    return builder.routes()
        .route(p -> p
            .path("/get")
            .filters(f -> f.addRequestHeader("Hello", "World"))
            .uri("http://httpbin.org:80"))
        .build();
}
CH4:D
@chad_d_stud_twitter
Mar 25 09:54
yup
Chris Overgaauw
@chrisovergaauw
Mar 25 09:54
uri should only contain the base url
so omit /actuator/info
CH4:D
@chad_d_stud_twitter
Mar 25 09:54
bummer
Chris Overgaauw
@chrisovergaauw
Mar 25 09:54
and the path is specified as /get
so either replace that with /actuator/info or whatever you like
CH4:D
@chad_d_stud_twitter
Mar 25 09:56
probably an invalid use case but is it possible to map /get to the remote's /actuator/info?
Chris Overgaauw
@chrisovergaauw
Mar 25 09:56
not invalid and it is possible. I don't know how to do it from the top of my head thoughh
try replacing f.addRequestHeader("Hello", "World") for something like f.rewritePath("/get","/actuator/info")
CH4:D
@chad_d_stud_twitter
Mar 25 09:57
can i do something similar to zuul like so?
http://mygateway/service01/actuator/info
goes to http://service01/actuator/info
Chris Overgaauw
@chrisovergaauw
Mar 25 09:57
you should probably google the exact syntax
CH4:D
@chad_d_stud_twitter
Mar 25 09:58
yeah, that's fine. thanks. @chrisovergaauw
regarding the zuul question. is it also possible?
Chris Overgaauw
@chrisovergaauw
Mar 25 09:59
Yes, you don't need a custom routelocator for that.
s-spindler
@s-spindler
Mar 25 10:00
Hi all! I have a Spring Cloud Gateway specific question: how can I start a background task on a different thread when processing a request? If I send it to another scheduler with publishOn the rest of the whole request is processed on that that scheduler, right?
Chris Overgaauw
@chrisovergaauw
Mar 25 10:00
basically you throw out the custom routelocator and you add spring.cloud.gateway.discovery.locator.enabled=true in your config
this expects your to have something on your classpath which implements discovery though
like eureka
CH4:D
@chad_d_stud_twitter
Mar 25 10:02
thanks again. i'll take it from here
Chris Overgaauw
@chrisovergaauw
Mar 25 10:02
good luck :-)
CH4:D
@chad_d_stud_twitter
Mar 25 10:03
yeah i'm famliar with eureka. we have one in production
s-spindler
@s-spindler
Mar 25 11:47

Hi all! I have a Spring Cloud Gateway specific question: how can I start a background task on a different thread when processing a request? If I send it to another scheduler with publishOn the rest of the whole request is processed on that that scheduler, right?

no one got any idea? :(