You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -89,17 +74,16 @@ The routes is a array table, like `{ {...}, {...}, {...} }`, Each element in the
89
74
90
75
The attributes of each element may contain these:
91
76
92
-
|name |option |description|
93
-
|-------- |--------|-----------|
94
-
|path |required|Client request uri, the default is a full match. But if the end of the path is `*`, it means that this is a prefix path. For example `/foo*`, it'll match `/foo/bar` or `/foo/glo/grey` etc. We can set multiple `path` by an array table, eg: `{"/", "/aa", "/bb"}`.|
95
-
|metadata |option |Will return this field if using `rx:match` to match route.|
96
-
|handler |option |Will call this function using `rx:dispatch` to match route.|
97
-
|host |option |Client request host, not only supports normal domain name, but also supports wildcard name, both `foo.com` and `*.foo.com` are valid. We can set multiple `host` by an array table, eg: `{"foo.com", "bar.com"}`.|
98
-
|remote_addr|option |Client remote address like `192.168.1.100`, and we can use CIDR format, eg `192.168.1.0/24`. BTW, In addition to supporting the IPv6 format, multiple IP addresses are allowed, this field will be an array table at this case, the elements of array shoud be a string IPv4 or IPv6 address. We can set multiple `remote_addr` by an array table, eg: `{"127.0.0.1", "192.0.0.0/8"}`.|
99
-
|method |option |It's an array table, we can put one or more method names together. Here is the valid method list: "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT" and "TRACE".|
100
-
|vars |option |It is an array of one or more {var, operator, val} elements. For example: {{var, operator, val}, {var, operator, val}, ...}. `{"arg_key", "==", "val"}` means the value of argument `key` expect to `val`.|
101
-
|filter_fun |option |User defined filter function, We can use it to achieve matching logic for special scenes. `radixtree` will only pass one parameter which named `vars` when matching route.|
102
-
77
+
|name |option |description|example|
78
+
|:-------- |:--------|:-----------|:-----|
79
+
|paths |required|A list of client request uri. The default is a full match, but if the end of the path is `*`, it means that this is a prefix path. For example `/foo*`, it'll match `/foo/bar` or `/foo/glo/grey` etc.|{"/", "/aa", "/bb"}|
80
+
|hosts |option |A list of client request host, not only supports normal domain name, but also supports wildcard name.|{"foo.com", "*.bar.com"}|
81
+
|remote_addrs|option |A list of client remote address(IPv4 and IPv6), and we can use CIDR format, eg `192.168.1.0/24`.|{"127.0.0.1", "192.0.0.0/8", "::1", "fe80::/32"}|
82
+
|methods |option |A list of method name. Here is full valid method list: "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT" and "TRACE".|{"GET", "POST"}|
83
+
|vars |option |A list of `{var, operator, val}`. For example: {{var, operator, val}, {var, operator, val}, ...}, `{"arg_name", "==", "json"}` means the value of argument `name` expect to `json`.|{{"arg_name", "==", "json"}, {"arg_age", ">", 18}}|
84
+
|filter_fun |option |User defined filter function, We can use it to achieve matching logic for special scenes. `radixtree` will only pass one parameter which named `vars` when matching route.|function(vars) return vars["arg_name"] == "json" end|
85
+
|metadata |option |Will return this field if using `rx:match` to match route.||
86
+
|handler |option |Will call this function using `rx:dispatch` to match route.||
103
87
[Back to TOC](#table-of-contents)
104
88
105
89
@@ -112,7 +96,7 @@ match
112
96
*`opts`: a Lua tale (optional).
113
97
*`method`: optional, method name of client request.
114
98
*`host`: optional, client request host, not only supports normal domain name, but also supports wildcard name, both `foo.com` and `*.foo.com` are valid.
115
-
*`remote_addr`: optional, client remote address like `192.168.1.100`, and we can use CIDR format, eg `192.168.1.0/24`.
99
+
*`remote_addr`: optional, client remote address like `192.168.1.100`.
116
100
*`vars`: optional, a Lua table to fetch variable, default value is `ngx.var` to fetch Ningx builtin variable.
117
101
118
102
Matchs the route by `method`, `path` and `host`, and return `metadata` if successful.
@@ -132,7 +116,7 @@ dispatch
132
116
*`opts`: a Lua tale (optional).
133
117
*`method`: optional, method name of client request.
134
118
*`host`: optional, client request host, not only supports normal domain name, but also supports wildcard name, both `foo.com` and `*.foo.com` are valid.
135
-
*`remote_addr`: optional, client remote address like `192.168.1.100`, and we can use CIDR format, eg `192.168.1.0/24`.
119
+
*`remote_addr`: optional, client remote address like `192.168.1.100`.
136
120
*`vars`: optional, a Lua table to fetch variable, default value is `ngx.var` to fetch Ningx builtin variable.
137
121
138
122
Dispatchs the route by `method`, `path` and `host`, and call `handler` function if successful.
0 commit comments