gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.07k stars 573 forks source link

How can i remove the "ETag" response header which is set in gobuffalo fileServer ? #2384

Closed galba-rp closed 9 months ago

galba-rp commented 1 year ago

ETag is set in route_mappings.go file

func (a App) fileServer(fs http.FileSystem) http.Handler { fsh := http.FileServer(fs) baseHandler := http.HandlerFunc(func(w http.ResponseWriter, r http.Request) {

    f, err := fs.Open(path.Clean(r.URL.Path))
    if os.IsNotExist(err) {
        eh := a.ErrorHandlers.Get(http.StatusNotFound)
        eh(http.StatusNotFound, fmt.Errorf("could not find %s", r.URL.Path), a.newContext(RouteInfo{}, w, r))
        return
    }

    stat, _ := f.Stat()
    w.Header().Add("ETag", fmt.Sprintf("%x", stat.ModTime().UnixNano()))
    maxAge := envy.Get(AssetsAgeVarName, "31536000")
    w.Header().Add("Cache-Control", maxAge)

    fsh.ServeHTTP(w, r)
})

if a.CompressFiles {
    return handlers.CompressHandler(baseHandler)
}

return baseHandler

}

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment. Otherwise, this will be closed in 7 days.

galba-rp commented 11 months ago

I will try to resolve it and submit a code proposal for this issue in the near future

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment. Otherwise, this will be closed in 7 days.

github-actions[bot] commented 9 months ago

This issue was closed because it has been stalled for 30+7 days with no activity.