From 4a5c5800313a9ed672de6ea6f3e37dfce4f8c2b1 Mon Sep 17 00:00:00 2001 From: Rikako Wu <496063163@qq.com> Date: Tue, 18 Apr 2023 20:37:30 +0800 Subject: [PATCH] =?UTF-8?q?Spring=20Cloud=20gateway=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring/Spring Cloud/Spring Cloud gateway.md | 42 ++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/spring/Spring Cloud/Spring Cloud gateway.md b/spring/Spring Cloud/Spring Cloud gateway.md index 5c34e7f..7b9d3ab 100644 --- a/spring/Spring Cloud/Spring Cloud gateway.md +++ b/spring/Spring Cloud/Spring Cloud gateway.md @@ -47,4 +47,44 @@ spring: ``` 该route匹配2017-01-20T17:42:47.789-07:00[America/Denver]该时间之后的任意请求 -### \ No newline at end of file +### Before Route Predicate Factory +Before route predicate factory接收一个`datetime`参数,参数为ZonedDateTime类型,该predicate匹配发生在某时间之前的请求。 +```yml +spring: + cloud: + gateway: + routes: + - id: before_route + uri: https://example.org + predicates: + - Before=2017-01-20T17:42:47.789-07:00[America/Denver] +``` +该route匹配发生在2017-01-20T17:42:47.789-07:00[America/Denver]之前的任意请求 +### Between Route Predicate Factory +Between Route Predicate Factory接收两个参数,都是ZonedDateTime类型,该predicate匹配发生在datetime1和datetime2之间的请求,其中第二个参数指定的时间必须位于第一个参数指定时间之后。如下指定了一个between predicate示例: +```yml +spring: + cloud: + gateway: + routes: + - id: between_route + uri: https://example.org + predicates: + - Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver] + +``` +### Cookie Route Predicate Factory +Cookie Route Predicate Factory接收两个参数,`name`和`regexp`。该predicate匹配请求中含有指定名称,并且cookie值满足`regexp`正则表达式。如下展示了一个cookie predicate示例: +```xml +spring: + cloud: + gateway: + routes: + - id: cookie_route + uri: https://example.org + predicates: + - Cookie=chocolate, ch.p +``` +上述cookie_route会匹配请求中含有name为chocolate的cookie,并且cookie值满足`ch.p`正则表达式的请求。 +### Header Route Predicate Factory +Header Route Predicate Factory接收两个参数,`header`和`regexp`。