-
Notifications
You must be signed in to change notification settings - Fork 12
Discussion: why not a custom handler signature? #13
Comments
If you did this I'd recommend the following:
Saying that, Go 1.7 is likely to stuff a Otherwise, a custom function type - i.e. |
Good points. I'll add:
Given all of the above, I'm stepping back from using Context at all, and will use the common signatures from net/http, even if this will cost a little bit in performance (matching twice or using a map/lock setup). |
@moraes Can I assume your latest commits and comments in #4 supersede the comment above? Postscript: totally get what you mean here regarding the ambiguity about where Adding it to |
Yes, you can assume that. I'll fix my statement: "I have a strong conviction that a router package should not require a custom handler signature for the sole purpose of passing route variables". This would be like a database package define their own handler signature to pass a connection link, or an auth package define their own handler signature to pass credentials etc. net/context exists to solve all of these, uh, contextual problems. In short, using a context parameter is unavoidable at this point, given the range of problems it solves with a unified signature. So we will follow Goji and I hope others will too. We revisit this when net/context is part of the standard library. |
The title says it all: I'd like to hear your opinions about the pros and cons to stay with the
func(http.ResponseWriter, *http.Request)
signature for handlers, and why not set one that accepts an extra variables parameter.The text was updated successfully, but these errors were encountered: