Spring Cloud-Zuul API Gateway
Spring Cloud-Zuul API Gateway
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
return null;
}
filterType(): Returns a String that stands for the type of the filter — in this case, ”PRE”.
filterOrder(): Gives the order in which this filter is to be run, relative to other filters.
shouldFilter(): Contains the logic that determines when to run this filter (this particular filter is
always run).
Run(): Contains the functionality of the filter.
Zuul filters store request and state information in (and share it by means of) the RequestContext .
You can use that to get at the HttpServletRequest and then log the HTTP method and URL of the
request before it is sent on its way.
Eureka:
All Micro service will 1st register in the Eureka server and this Eureka server knows all the
service applications running on each port and name of that application. Eureka Server is also
known as Discovery Server.
By default Eureka server will run at port :8761
The @EnableEurekaServer annotation is used to make your Spring Boot application
acts as a Eureka Server
By default Eureka Server will get registers itself into the discovery.
eureka.client.registerWithEureka = false
eureka.client.fetchRegistry = false
server.port = 8761
@EnableEurekaClient: this will make the service as client and it will register into the
eureka server.
eureka.client.serviceUrl.defaultZone =
http://localhost:8761/eureka
spring.application.name = eurekaclient