You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a specific situation where I don't want to let developer override response header if the header key matched.
So, whenever developer overrides response header supposedly like this:
router.GET("/:id", func(ctx *gin.Context) {
ctx.Header("Content-Type", "application/json") // should panic or just do not set it.
ctx.Header("X-Any-Other-Header", "other header") // Okay set it.
// ...
}
I want to allow setting of any header is okay but setting of specific header should panic. In this case the header is "Content-Type". So, application should result in panic or just do not set it.
Is there a way to achieve this? I couldn't think of a solution because middleware runs first and this GET func runs later.
The text was updated successfully, but these errors were encountered:
Re-opening this issue because code using afterMiddlewareWriter as in the linked issue returns gin default status code and not able to set my own. Thus, looking for better alternative to this.
I have a specific situation where I don't want to let developer override response header if the header key matched.
So, whenever developer overrides response header supposedly like this:
I want to allow setting of any header is okay but setting of specific header should panic. In this case the header is "Content-Type". So, application should result in panic or just do not set it.
Is there a way to achieve this? I couldn't think of a solution because middleware runs first and this
GET
func runs later.The text was updated successfully, but these errors were encountered: