Request Context() #28
-
Hey Everyone, I would like to thank Maxim and Anton for this great library! Coming from the .Net world, this is exactly what I have needed. A little bit of background....we use JWT and have some middleware that authenticates each request. This middleware retrieves the claims from the JWT, creates a credentials struct and attaches it to the context. Is it possible to have this struct somehow injected into another struct. I dont want to have to pass this from the controller/handler all the way down the chain. Thank You, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @doppl-neal! Hopefully, I understand your concern correctly. Passing request-scoped data with context and accepting it as the first argument of your functions is a common way in go. As for this library, it was made for app initialization on purpose. Because of that, it is not recommended to resolve request-scoped data in runtime. Please give an example of what you want if you need any more help. |
Beta Was this translation helpful? Give feedback.
Hello @doppl-neal! Hopefully, I understand your concern correctly.
Passing request-scoped data with context and accepting it as the first argument of your functions is a common way in go.
As for this library, it was made for app initialization on purpose. Because of that, it is not recommended to resolve request-scoped data in runtime.
Please give an example of what you want if you need any more help.