-
Notifications
You must be signed in to change notification settings - Fork 209
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
Doesn't work with gin-gonic #327
Comments
If you're using a framework like gin-gonic which takes over the response writer you need to ensure proper ordering of middlewares. I don't generally help sort out custom frameworks issues though. This library works fine with the stdlib http package and many other packages like chi and httprouter. |
I just ran into this and did some debugging. If you're using the example from https://github.com/jesusvazquez/authboss-gin-sample that's using github.com/gwatts/gin-adapter to convert regular middleware into Gin middleware. If you step through the flow in a debugger you see that func (h *connectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
state := r.Context().Value(h).(*middlewareCtx)
defer func(r *http.Request) { state.ctx.Request = r }(state.ctx.Request)
defer func(w gin.ResponseWriter) { state.ctx.Writer = w }(state.ctx.Writer)
state.ctx.Request = r
state.ctx.Writer = swap(state.ctx.Writer, w)
state.childCalled = true
state.ctx.Next()
} Note that swaps out the response writer via the To make this work we'd need an alternative form of adapter but I'm not sure how that could work. authboss creates a new response writer derived from the |
Oh! It looks like maybe somebody found a workaround. This is a update to |
When using with gin-gonic with authboss I get exception:
Reply steps:
router.GET("/status", status)
curl localhost:3000/admin/
-> an exception is thrownThe text was updated successfully, but these errors were encountered: