Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring cloud gateway and eureka server

I have been trying to find a running example of spring cloud gateway integrated with eureka server and also with some Hystrix examples but I could't find so far. Are there any place where I could find it? I really would like to see spring cloud gateway in use, replacing my current Zuul API service.

Thanks!

like image 979
Felipe Avatar asked Sep 08 '17 09:09

Felipe


People also ask

What is the difference between API Gateway and Eureka server?

So Eureka acts as service registry for these services (service-name, hostname and its IP). Spring Cloud API Gateway acts as a single point of entry for any microservice call. It can work as a proxy service to route a request to the concerned microservice, abstracting the producer details.

How do I connect API gateway to Eureka server?

Access the HTTP Service of Eureka Client​Set the listening ports to 8080 , 8081 , and 8082 , and start three Spring Boot instances. After completion, use a browser to access port 8761 of Eureka Server to view the results of service registration.

What is difference between spring Cloud Gateway and Zuul?

Zuul is built on servlet 2.5 (works with 3. x), using blocking APIs. It doesn't support any long lived connections, like websockets. Gateway is built on Spring Framework 5, Project Reactor and Spring Boot 2 using non-blocking APIs.


1 Answers

In Finchley.M5, API has changed

@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder)
{
    GatewayFilter filter = new RewritePathGatewayFilterFactory()
            .apply("/admin/(?<segment>.*)", "/${segment}");

    return builder.routes()
            .route(r -> r.path("/admin/**")
                    .filter(filter)
                    //.uri("http://localhost:3000"))
                    .uri("lb://admin"))  // with load balancer through Eureka
            .build();
}
like image 111
HelLViS69 Avatar answered Oct 12 '22 03:10

HelLViS69