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 middleware overview #395

Merged
merged 4 commits into from
Nov 7, 2022

Conversation

rogerogers
Copy link
Contributor

Signed-off-by: rogerogers rogers@rogerogers.com

What type of PR is this?

docs: improve middleware overview

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

en: improve middleware overview doc
zh: 优化中间件概览文档

Which issue(s) this PR fixes:

Signed-off-by: rogerogers <rogers@rogerogers.com>

```go
// One way
func MyMiddleware() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
// pre-handle
...
// ...
c.Next(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

这块是可以加一句,if there is no 'post-handle' logic, the 'c.Next(ctx)' can be omitted.

Copy link
Member

@welkeyever welkeyever Nov 6, 2022

Choose a reason for hiding this comment

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

.Next能否忽略的不是说是否存在后处理逻辑,而是后续是否需要保证该中间件和业务handler在一条函数调用栈上;类似panic recovery这种就是没有后处理逻辑,但.Next却必须保留的原因如此

Copy link
Member

Choose a reason for hiding this comment

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

24行应该已经说明了

rogerogers and others added 2 commits October 23, 2022 20:47
Signed-off-by: rogerogers <rogers@rogerogers.com>
@rogerogers
Copy link
Contributor Author

done

@GuangmingLuo GuangmingLuo merged commit 0aada6d into cloudwego:main Nov 7, 2022
@rogerogers rogerogers deleted the feature/middleware branch November 7, 2022 14:27
YUandJIANG pushed a commit to YUandJIANG/cloudwego.github.io that referenced this pull request Nov 10, 2022
* docs: improve middleware overview

Signed-off-by: rogerogers <rogers@rogerogers.com>

* docs: middleware cr fix

Signed-off-by: rogerogers <rogers@rogerogers.com>

Signed-off-by: rogerogers <rogers@rogerogers.com>
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