This is part 8 of Developing Instagram Clone series, other parts are linked below
In Microservices architecture the system is split into multiple services, these services shouldn’t be visible to the consumer (the front-end in our case).
You should provide a unified interface to the consumers, this unified interface is the gateway service.
In our case we are using API gateway to provide a single entry point for our microservices and to handle authentication and authorization.
Netflix Zuul and Spring cloud
Netflix created and opened sourced its Zuul proxy server, Spring has developed a wrapper around Netflix Zuul, so that it can be easily integrated into Spring based applications. This wrapper comes as a part of the Spring Cloud framework.
To add spring cloud Zuul to your project, you need to add this dependency to your pom.xml file
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId> </dependency>
And annotate the InstaApiGatewayApplication with @EnableZuulProxy
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class InstaApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(InstaApiGatewayApplication.class, args);
}
}
Clone insta-api-gateway and let’s define our routes.
#microservices #developer #api