-
Notifications
You must be signed in to change notification settings - Fork 65
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
fix lost trace when multi middleware handlerFunc #167
Conversation
Let's wait for project lead back from vacation. It should be next Monday. |
|
||
func isFirstHandle(c interface{}) bool { | ||
if context, ok := c.(*nativeContext); ok { | ||
return context.index < 0 |
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.
Following your diagram in the comment, I think It should equal zero? Please correct me if am wrong.
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.
In fact, the index is the index of HandlersChain, it is reset to -1 at the beginning of each request, and then incremented and executes the handlers[index] in the #Next()
.
func (c *Context) Next() {
c.index++
for c.index < int8(len(c.handlers)) {
c.handlers[c.index](c)
c.index++
}
}
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.
Then, could you help to add a comment to explain this mechanism in the code?
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.
ok
Please update the CHANGES.md, thanks. |
using the index of
[]HandlerFunc
, determine if the current is the first HandlerFunc, and then handle the enhancement#11852