This is part 8 of Developing Instagram Clone series, other parts are linked below

  1. Developing Instagram Clone: Introduction.
  2. Developing Instagram Clone: Discovery Service.
  3. Developing Instagram Clone: Auth Service
  4. Developing Instagram Clone: Media Service.
  5. Developing Instagram Clone: Post Service.
  6. Developing Instagram Clone: Graph Service.
  7. Developing Instagram Clone: Newsfeed Service.
  8. Developing Instagram Clone: Gateway Service.
  9. Developing Instagram Clone: Front-end Service

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.

API Gateway Benefits

  • Serves as a single point of entry: An API gateway is a single point-of-entry (or “gateway”) for the group of Microservices that sit behind it.
  • **Authentication and authorization: **An API gateway makes sure that the client has the rights to access the specified resource.
  • An API gateway can perform a wide variety of integration tasks for microservices such as rate limiting, logging, caching, composition, monitoring, protocol translations and many more.

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

Microservices In Practice: Developing Instagram Clone —Gateway Service
6.05 GEEK