oapi-codegen
oapi-codegen copied to clipboard
Create a new context before passing it to strict handlers
Hello,
I don't know if this is relevant but when using the authenticate example and for example setting the current_user in the echo context after performing my authentication / authorization logic I can't retrieve it because only the context of the *http.Request is passed to the strict handler and not the echo context.
I create a new context and inject the echo context with the key defined in the middleware package so in every strict handler we can now grab the echo context or the request handler by calling .Request() method on the echo context.
Well I don't know if this is clear, don't hesitate to tell me why this is a bad idea if this is one !
You are right, this is a better way to pass request context downstream, however it is a breaking change. I do think it's worth creating a breakage to fix this.
Hey, I'm not very sure about what you mean by breakage but I would be glad to do it if I can ! I use this context passing a lot in my projects so I would be happy to do the require work.
Also sorry for the late response !
Either I'm missing something, or echo with StrictServer is hardly unusable without a custom template, since we cannot update the request's context in a middleware, or access Echo's context in the handlers. This PR feels critical to me.