Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@VojtechVitek
Copy link
Contributor

Something for consideration:

middleware.Timeout() and middleware.CloseNotify don't need to cancel() the context when the underlying handlers return. We might want to use explicit middleware.Cancel instead.

This way, all handlers would have context.Background() as a base context and it'd be up to developers to specify when the "context flow" ends. Timeout should only cancel underlying contexts on timeout. CloseNotify should only cancel underlying contexts on <-w.CloseNotify(). Explicit over magic.

If we wanted to have strict boundaries for context lifetime in the handler chain, we'd need to use context.WithCancel() instead of context.Background() in mux.ServeHTTPC().

@VojtechVitek
Copy link
Contributor Author

Closing this PR -- I don't think we need this anymore, since Timeout and CloseNotify close their contexts in defer functions, which is imho the correct behavior.

@pkieltyka pkieltyka deleted the cancel branch July 26, 2016 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants