go-aah / aah

A secure, flexible, rapid Go web framework
https://aahframework.org
MIT License
691 stars 33 forks source link

Add a way to delete headers on an app-wide basis #181

Closed pharrisee closed 6 years ago

pharrisee commented 6 years ago

After reading this:

https://www.fastly.com/blog/headers-we-dont-want

It struck me that there doesn't seem to be a way to remove headers on an app-wide basis.

What would be the best way to achieve this? OnPreReply hook?

Could there be a config option for custom header inclusion and exclusion?


jeevatkm commented 6 years ago

@pharrisee Thanks for sharing. Yeah it is informative article.

You have guess it correctly, best spot is OnPreReply.


My thoughts; discussed headers in the article mostly applicable to proxy server, cache server, etc For e.g. CDN's.

As an application; header originates here. aah has OOTB configs -

jeevatkm commented 6 years ago

@pharrisee Above information; does it fulfill your need?

jeevatkm commented 6 years ago

@pharrisee I have thought about your idea. A way to manipulate the headers for each request at application level.

Having more flexibility and control of reply in aah framework is important. So I'm planning to add following enhancement in HTTP Engine-

aah.AppHTTPEngine().OnHeaderReply(HandleHeader)

func HandleHeader(e *aah.Event) {
    hdr := e.Data.(http.Header)

    // Header instance is direct reference to http.ResponseWritter
    // Change reflects immediately :)
    //
    // logic goes here
}

Converting this issue as Enhancement.

jeevatkm commented 6 years ago

Its done 😄