Current location - Quotes Website - Signature design - Gateway java
Gateway java
What is gateway java? Let's find out.

Gateway aims to provide a simple and effective unified API routing management method for microservice architecture, with the goal of replacing ZUUL. Such as safety, monitoring/burying points and current limitation.

Why should we use a gateway?

1, Spring Cloud Gateway can be regarded as an upgraded version and substitute of Zuul1.x. Netty was used to realize asynchronous IO earlier than Zuul 2, thus realizing a simpler and more efficient API gateway that closely cooperates with Spring Cloud than Zuul1.x. ..

2. Routers and filters in 2.Spring Cloud Gateway are clearly distinguished, and a big feature is that many out-of-the-box functions are built in, which can be used through SpringBoot configuration or manual coding chain call.

3. For example, there are 10 routers built in, so that we can directly configure the route according to the header, path, host or random query.

For example, the universal filter and the global filter are distinguished, and 20 kinds of filters and 9 kinds of global filters are built in, which can also be used directly. Of course, it is also convenient to customize the filter.

So how to use gateway?

To put it bluntly, predict is to realize a set of matching rules, so that requests can come and find the corresponding route for processing. Next, we will use several predictions built into Spring Cloud GateWay.

By time matching:

For example, if we set the forwarding date to 20 19 1, I can configure it like this:

Spring: Cloud: Gateway:? Route:-? id:? Time _ route uri:? Predicate:? -? After = 2018-01-20t06: 06: 06+08: 00 [Asia/Shanghai]

Of course, in addition to time matching, we can also use the following methods:

1, matched by Cookie

2. Through host matching

3. Match as required.

4. By requesting path matching

5. By requesting parameter matching

6. Match by requesting the ip address.