--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'd be happy to see Context move into the standard library. If this is something that should happen for 1.6, please let me know.
The only change I considered for context removing the Deadline method and replacing it with a context value added via a separate deadline package. Doing this would remove the context package's dependence on time and so permit context to be imported anywhere in the standard library. I discussed this with others when I first open sourced context, and they said it's fine as is.
I'd like to do the move to the standard library myself, if we decide to do it.
Sounds good. Was that last sentence supposed to say 1.7 dev?
You received this message because you are subscribed to a topic in the Google Groups "golang-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-dev/cQs1z9LrJDU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-dev+...@googlegroups.com.
Isn't the act of saving the derived context back to the request the same thing as passing the derived context to a chained handler via arg?
--
You received this message because you are subscribed to a topic in the Google Groups "golang-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-dev/cQs1z9LrJDU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-dev+...@googlegroups.com.
What I'm arguing against is that we put context into request structure inherently mutable through pointer. It's tempting, but goes against the very idea of the contexts. I'll repeat: if somebody needs common storage for upstream and downstream handlers, they should do just that, put a lock around map[string]interface{} and be done with it.
type ContextualisedHandler interface { ServeHTTPC(context.Context, http.ResponseWriter, *http.Request)}
func AppengineContext(next http.ContextualisedHandler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { next.ServeHTTPC(appengine.NewContext(r), w, r) // now every subhandler must be an HandlerC } return http.HandlerFunc(fn)}
func StopWithServerContext(next http.ContextualisedHandler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { next.ServeHTTPC(r.Context, w, r) } return http.HandlerFunc(fn)}
Just wondering about the interest level and any suggested approaches for adding context.Context-based http handler support?I submitted a patch that adds a context.Context handler interface to the existing net/context/ctxhttp (https://github.com/golang/net/tree/master/context/ctxhttp) package and looking for some feedback.The approach:* First steps in a context.Context http handler world - added to a core “support” subpackage like ctxhttp* Control a request - timeout, cancel, store values* Standardized middleware that require a request context - versus the constant invention of inoperable handlers. See the different signatures of the popular mux libraries: goji, martini, gin, httprouter, gorilla, negroni, and it goes on.* Optional and compatible - not to compete or break the standard libraryCode diff:
After considering all of the approaches here, I am starting to suspect that maybe a "standard middleware interface" is actually a harmful idea, and should not be encouraged with changes to the standard library. While I agree that we should prevent the "constant invention of inoperable handlers," it seems to me that the real reason we have this problem is that we have wrongly assumed that handlers should be the mechanism of code reuse.
type key int
ctx = context.WithValue(ctx, key(0), someval)
That is, checking a bag of values from a chainable context has two issues as I see: 1. namespace conflicts...