mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
README updates
This commit is contained in:
parent
d436628ae1
commit
41b58a592e
14
README.MD
14
README.MD
@ -204,7 +204,7 @@ go get -u gitee.com/johng/gf
|
||||
使用```:name```方式进行匹配(```name```为自定义的匹配名称),匹配成功后对应匹配参数会被解析为GET参数并传递给注册的服务使用。
|
||||
|
||||
匹配示例1:
|
||||
```shell
|
||||
```text
|
||||
rule: /user/:user
|
||||
|
||||
/user/john/profile no match
|
||||
@ -213,7 +213,7 @@ go get -u gitee.com/johng/gf
|
||||
/user/you match
|
||||
```
|
||||
匹配示例2:
|
||||
```shell
|
||||
```text
|
||||
rule: /:name/action
|
||||
|
||||
/john/name no match
|
||||
@ -223,7 +223,7 @@ go get -u gitee.com/johng/gf
|
||||
/smith/action match
|
||||
```
|
||||
匹配示例3:
|
||||
```shell
|
||||
```text
|
||||
rule: /:name/:action
|
||||
|
||||
/john/name match
|
||||
@ -238,7 +238,7 @@ go get -u gitee.com/johng/gf
|
||||
使用```*any```方式进行匹配(```any```为自定义的匹配名称),一般常用语末尾匹配,将会匹配URI随后所有的参数,并将匹配参数解析为GET参数并传递给注册的服务使用。
|
||||
|
||||
匹配示例1:
|
||||
```shell
|
||||
```html
|
||||
rule: /src/*path
|
||||
|
||||
/src/ match
|
||||
@ -248,7 +248,7 @@ go get -u gitee.com/johng/gf
|
||||
/user/john no match
|
||||
```
|
||||
匹配示例2:
|
||||
```shell
|
||||
```html
|
||||
rule: /src/*path/:action
|
||||
|
||||
/src/ no match
|
||||
@ -257,7 +257,7 @@ go get -u gitee.com/johng/gf
|
||||
/src/subdir/file.go/del match
|
||||
```
|
||||
匹配示例3:
|
||||
```shell
|
||||
```html
|
||||
rule: /src/*path/show
|
||||
|
||||
/src/ no match
|
||||
@ -271,7 +271,7 @@ go get -u gitee.com/johng/gf
|
||||
|
||||
优先级控制最主要的是两点因素,1、层级越深的规则优先级越高;2、命名匹配比模糊匹配优先级高。
|
||||
我们来看示例(左边的规则优先级比右边高):
|
||||
```shell
|
||||
```html
|
||||
/user/name > /user/:action
|
||||
/:name/info > /:name/:action
|
||||
/:name/:action > /:name/*action
|
||||
|
Loading…
Reference in New Issue
Block a user