This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12589|Reply: 2

[Source] Spring Cloud Gateway route yml and json configuration

[Copy link]
Posted on 2022-1-10 09:22:40 | | |
preface

Only by understanding the configuration of the gateway can we understand what can be done with the gateway, so that it can be better applied in product development.

The yml configuration written below refers to the configuration written in the configuration file, and the JSON configuration refers to the configuration using dynamic routing, where there is a database or nacos.

1. Predicates

The main role of Predicates is to configure rules for routing matching requests

1. Http-related

Path configuration matching rules for the request path

2. Cookie configuration pair

The first value in the cookie is key, and the second is value. The following example matches the cookie settingschocolate:ch.prequest

3. Header matching

The content set in the http request, http-header can be matched by setting X-Request-Id:\d+, and the second parameter is a regular expression

4. Host matching

http request host, matching all hosts**.somehost.comrequest

5. Method matches the Http request header

6. Query matching

The query parameter in the HTTP request can be matched by the request with param1=value in the request

7. RemoteAddr matching

RemoteAddr in the request

8. Time correlation

After setting the time, it can be accessed

Beforecan be accessed before setting the time

Before

9. Weight routing

At least two groups of routes can be configured with weight routes, and several routes will be randomly accessed based on the weights


2. Filters

1. Path rewriting

2. Modify the request header

3. Modify the request parameters

4. Modify the response parameters

5. Path prefix enhancement

6. Delete the path prefix

7. Request to keep the original host

8. Redirect

9. Circuit breaker

10. Integrate Redis native support request throttling

11. Delete the request header attribute

12. Delete the response header attribute

13. Rewrite the response header

14. Reset the request path

15. Set the response head

In the next process, change the response header X-Response-Foo to Bar

16. Set the HTTP status

17. Set the file transfer size

18. Fail and try again

Transferred from:The hyperlink login is visible.





Previous:DELL T340 ESXI builds a TrueNAS drive-thru drive
Next:The Spring jackson-dataformat-xml settings interface returns JSON format by default
 Landlord| Posted on 2022-2-7 11:42:17 |
Set some interfaces to prohibit access through the gateway and return a 401 status code directly

 Landlord| Posted on 2022-2-7 13:37:23 |
Filter factories built into Spring Cloud Gateway
https://www.itsvse.com/thread-10248-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com