Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve route doc #361

Merged
merged 1 commit into from
Sep 29, 2022
Merged

Conversation

li-jin-gou
Copy link
Member

What type of PR is this?

doc

What this PR does / why we need it (en: English/zh: Chinese):

en: improve route doc
zh: 改善路由文档中文部分

Which issue(s) this PR fixes:

@li-jin-gou li-jin-gou force-pushed the docs/router_improve branch 2 times, most recently from ed7ec4d to bcc689c Compare September 21, 2022 14:09
| `Hertz.PATCH` | 用于注册 HTTP Method 为 PATCH 的方法 |
| `Hertz.HEAD` | 用于注册 HTTP Method 为 HEAD 的方法 |
| `Hertz.OPTIONS` | 用于注册 HTTP Method 为 OPTIONS 的方法 |
| `Hertz.Handle` | 这个方法支持用户手动传入 HTTP Method 用来注册方法,当用于注册普通的 HTTP Method 方法时和上述的方法作用是一致,但是这个方法同时支持用于注册自定义 HTTP Method 方法 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「是一致」->「是一致的」,这个方法同时也支持用于注册自定义 HTTP Method 方法。(感觉这样更通顺些?:D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image


### 使用匿名函数与装饰器注册路由

在使用匿名函数或装饰器注册路由时,如果我们需要使用 `RequestContext.HandlerName()` 获取 handler 名称会获取到错误的名称。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果我们需要使用 RequestContext.HandlerName() 获取 handler 名称会获取到错误的名称。 ->「如果我们使用RequestContext.HandlerName() 获取 handler 名称则会获取到错误的名称。」

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@li-jin-gou
Copy link
Member Author

Welcome CR and not merged for now


如果我们设置`/src/*filepath`路由,匹配情况如下
如果我们设置`/src/*path`路由,匹配情况如下

| path | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| path | | -> | 路径 | 是否匹配 |

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@li-jin-gou li-jin-gou force-pushed the docs/router_improve branch 2 times, most recently from 507b813 to 0779207 Compare September 22, 2022 03:23

### 获取路由注册信息

Hertz 提供了 `Routes` 获取注册的路由信息(http method、http path、handler name)供用户使用.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该使用中文标点符号,typo:使用. -> 使用。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@li-jin-gou li-jin-gou changed the title doc: improve route doc (WIP)doc: improve route doc Sep 25, 2022
@li-jin-gou li-jin-gou force-pushed the docs/router_improve branch 3 times, most recently from f6832bb to cba641c Compare September 26, 2022 05:51
@li-jin-gou li-jin-gou changed the title (WIP)doc: improve route doc (WIP)docs: improve route doc Sep 28, 2022
@li-jin-gou li-jin-gou changed the title (WIP)docs: improve route doc docs: improve route doc Sep 28, 2022
Comment on lines 64 to 66
// will registers a route that matches all the HTTP methods.
h.Any("/ping_any", func(ctx context.Context, c *app.RequestContext) {
c.String(consts.StatusOK,"any")
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 为啥只在这个注册方法加了注释,其它方法要不要也加呢?
  2. consts.StatusOK,"any" 少了空格

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉这个注释了


### 获取路由注册信息

Hertz 提供了 `Routes` 获取注册的路由信息(http method、http path、handler name)供用户使用。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 Routes 的结构体也贴一下吧,会清晰一些

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@li-jin-gou li-jin-gou force-pushed the docs/router_improve branch 7 times, most recently from 6c3c59f to 0a54cdc Compare September 29, 2022 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

5 participants