You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "starsz (via GitHub)" <gi...@apache.org> on 2023/03/28 09:15:59 UTC

[GitHub] [apisix] starsz commented on a diff in pull request #9070: docs: Examples for Route Matching

starsz commented on code in PR #9070:
URL: https://github.com/apache/apisix/pull/9070#discussion_r1150280856


##########
docs/en/latest/architecture-design/apisix.md:
##########
@@ -49,3 +49,70 @@ The diagram below shows how APISIX handles an incoming request and applies corre
 The chart below shows the order in which different types of Plugin are applied to a request:
 
 ![flow-plugin-internal](https://raw.githubusercontent.com/apache/apisix/master/docs/assets/images/flow-plugin-internal.png)
+
+## Examples of route matching
+
+1. Host + URI: This criterion matches requests based on the combination of the host and URI. For example, you could use this to match all requests to https://example.com/api.

Review Comment:
   > match all requests to https://example.com/api ?
   
   Or `https://example.com/foo/bar`?



##########
docs/en/latest/architecture-design/apisix.md:
##########
@@ -49,3 +49,70 @@ The diagram below shows how APISIX handles an incoming request and applies corre
 The chart below shows the order in which different types of Plugin are applied to a request:
 
 ![flow-plugin-internal](https://raw.githubusercontent.com/apache/apisix/master/docs/assets/images/flow-plugin-internal.png)
+
+## Examples of route matching
+
+1. Host + URI: This criterion matches requests based on the combination of the host and URI. For example, you could use this to match all requests to https://example.com/api.
+
+```
+{
+    "uri": "/foo/bar",
+    "host": "example.com",
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "httpbin.org:80": 1
+        }
+    }
+}
+
+```
+
+2. Host + URI + Vars: This criterion matches requests based on the combination of the host, URI, and variables extracted from the URI using regular expressions. For example, you could use this to match all requests to https://example.com/api/users/123, where 123 is a variable extracted from the URI.

Review Comment:
   ```
   https://example.com/api/users/123,
   ``` ? 
   Are you sure ?



##########
docs/en/latest/architecture-design/apisix.md:
##########
@@ -49,3 +49,70 @@ The diagram below shows how APISIX handles an incoming request and applies corre
 The chart below shows the order in which different types of Plugin are applied to a request:
 
 ![flow-plugin-internal](https://raw.githubusercontent.com/apache/apisix/master/docs/assets/images/flow-plugin-internal.png)
+
+## Examples of route matching
+
+1. Host + URI: This criterion matches requests based on the combination of the host and URI. For example, you could use this to match all requests to https://example.com/api.
+
+```
+{
+    "uri": "/foo/bar",
+    "host": "example.com",
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "httpbin.org:80": 1
+        }
+    }
+}
+
+```
+
+2. Host + URI + Vars: This criterion matches requests based on the combination of the host, URI, and variables extracted from the URI using regular expressions. For example, you could use this to match all requests to https://example.com/api/users/123, where 123 is a variable extracted from the URI.
+
+```
+{
+    "uri": "/foo/bar",
+    "host": "example.com",
+    "vars": {
+        "foo": "bar"
+    },
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "httpbin.org:80": 1
+        }
+    }
+}
+
+```
+
+3. Host + URI + Vars + FilterFunctions: This criterion matches requests based on the combination of the host, URI, variables extracted from the URI using regular expressions, and the output of a user-defined filter function. For example, you could use this to match all requests to https://example.com/api/users/123 where the variable 123 represents a user ID that is valid in your application's database.

Review Comment:
   Ditto.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org