These are chat archives for gin-gonic/gin

10th
Apr 2017
Leo Adamek
@LeoAdamek
Apr 10 2017 10:04
Hi all, I've written a simple middleware to aid integrating NewRelic into my app, but even though before calling c.Next() in the middleware I call c.Set("newrelic.tx", tx) -- In my handlers c.MustGet("newrelic.tx") fails
actually my middleware doesn't appear to get called at all
Leo Adamek
@LeoAdamek
Apr 10 2017 10:23
actually, any middleware I'm setting stuff on context for isn't setting it.
Anyone else experience this issue where custom set values on the context don't actually store?
Leo Adamek
@LeoAdamek
Apr 10 2017 10:37
actually, looks like none of my middleware is being called
Leo Adamek
@LeoAdamek
Apr 10 2017 10:53
Anyone??
Hello?
Thomas Boerger
@tboerger
Apr 10 2017 11:01
I can't confirm that
Leo Adamek
@LeoAdamek
Apr 10 2017 13:08
I mean I may just be going about this the wrong way tbh
trying to instrument my app with NewRelic but obviously there's lots of stuff which isn't inside the http context which needs tracing
Maciej
@nazwa
Apr 10 2017 13:18
Hi @LeoAdamek Could you pm me your middleware and how are you "activating" it?
Or even better, are you sure the middleware is actually called at all?
Leo Adamek
@LeoAdamek
Apr 10 2017 13:19
The middleware func isn't getting called for some reason
even though its applied at the top-level
Maciej
@nazwa
Apr 10 2017 13:20
Maybe you assiged it to a subgroup, which is never used?
Leo Adamek
@LeoAdamek
Apr 10 2017 13:20
^ Like I said, I assigned it at the very top level
app := gin.New()
app.Use(myMiddleware())
Maciej
@nazwa
Apr 10 2017 14:36
fyi, the solution to the above was to add middleware BEFORE routes :)
Leo Adamek
@LeoAdamek
Apr 10 2017 15:17
^ Is that in docs btw?
feel like it should be if not
Thomas Boerger
@tboerger
Apr 10 2017 20:15
But that way it must be called, are you sure your middleware is written correctly? :)
Maciej
@nazwa
Apr 10 2017 21:45
@tboerger indeed - that is the way. @LeoAdamek was adding them after the routes , which is why they never got called :)