gobuffalo/buffalo

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

galba-rp opened this issue · 4 comments

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

}

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.

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

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.

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