-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
How to add a value into the request context from a middleware function? #1180
Comments
Hello @Julio-Guerra ! I see, so you need a way to override the However, I have an obligation to warn you that the std Thanks, |
… the request for any incoming request changes - #1180
You went fast 😄 But indeed, other Go frameworks have similar
Yes, it does a shallow copy. I am not a fan of this Thanks for your support! |
Yes, I was in turbo mode yesterday as well :) We could check the I thank you for the question!! |
Hello @Julio-Guerra, sorry for the delay but I've just read an issue inside your go-agent project 28 days ago, here, I thought that was solved with Lines 117 to 128 in 3cd0837
Let's give you a sample code and tell me if that suits your case: newRequest := ctx.Request().WithContext(yours go-agent's sql standard context.Context)
ctx.ResetRequest(newRequest) Also the FromStdWithNext sets this for any case the net/http Request's context modified. Did you mean that you wait the v11.2.0 to be released or the solution doesn't fix your issue? (although you can Thanks! |
… the request for any incoming request changes - kataras#1180 Former-commit-id: 764bf26bcaa3b7bdae0a2bdbf3bf2b6f8c5c546e
Hi!
I am implementing a middleware function and I would like to store a value into the request context so that handlers can access it from the Iris context but also from the request context, in case they only pass the request to sub-functions in their handlers.
Storing a value into the Iris context from a middleware function is indeed easy (
c.Values().Set(key, val)
), but what about the request's:But from there, I couldn't find any way to store the new request created by
WithContext()
into Iris' context.I thought
FromStdWithNext()
would help me on this but the request pointer passed tonext()
is ignored (https://github.com/kataras/iris/blob/master/core/handlerconv/from_std.go#L75).Thanks for your help!
The text was updated successfully, but these errors were encountered: