-
Notifications
You must be signed in to change notification settings - Fork 237
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
doc: add docs for request id middleware #379
Conversation
content/en/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
可以参考 jwt 的 pr #369 优化修改一下哈 |
content/zh/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
content/en/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
函数签名: | ||
|
||
```go | ||
// Generator类型是func() string的别名 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英文和中文之间缺少空格,很多注释里都有这个问题,请仔细查看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thx
|
||
上述**示例代码**中,只传入了两项自定义的配置。关于 `config` 的更多常用配置如下: | ||
|
||
| 参数 | 介绍 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为使用了 functional option 的方式,config struct 默认是隐藏的,这样突然进行说明其实显得很突兀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
## 配置 | ||
|
||
Hertz 通过使用中间件,可以在响应头中添加一个键为 `X-Request-ID` 的标识符,如果在请求头中设置了 `X-Request-ID` 字段,则会在响应头中将 `X-Request-ID` 原样返回。 | ||
其中 `config` 结构体定义了 Request ID 的配置信息,并提供了默认配置,用户也可以依据业务场景进行定制。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该不描述 config struct,该改一下描述了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
--- | ||
|
||
`X-Request-ID` 是一种HTTP非标准响应字段,通常用来关联客户端和服务器之间的HTTP请求。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X-Request-ID
是一种HTTP非标准响应字段,通常用来关联客户端和服务器之间的HTTP请求。 ->
X-Request-ID
在 HTTP Headers 中是一种非标准响应字段,通常用于关联客户端和服务器之间的 HTTP 请求。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
--- | ||
|
||
`X-Request-ID` 是一种HTTP非标准响应字段,通常用来关联客户端和服务器之间的HTTP请求。 | ||
Hertz 也提供了 Request ID 的[实现](https://github.com/hertz-contrib/requestid),参考了 gin 的[实现](https://github.com/gin-contrib/requestid)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
语序有些问题,阅读起来不是很流畅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
) | ||
|
||
func main() { | ||
h := server.Default() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码缩进有些问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
content/en/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
content/zh/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
content/zh/docs/hertz/tutorials/basic-feature/middleware/requestid.md
Outdated
Show resolved
Hide resolved
|
||
| configuration | Description | | ||
|---------------|--------------------------------------------------------------------------------------------| | ||
| generator | Define a function that generates a Request ID. By default, a UUID identifier is generated. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方 WIth*** 吧 因为是配置介绍,但是属性都是私有的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
* [WIP]doc: add docs for request id middleware * standardize code format * improve request id doc * standardizing doc * change weight * improve requestid doc by cr * Optimize code indentation * fix typo * improve document readability * format code
What type of PR is this?
docs
What this PR does / why we need it (en: English/zh: Chinese):
en: add docs for Request ID middleware
zh: 添加Request ID中间件的文档