func fileHandler(h http.Handler, cacheMaxAge string) http.HandlerFunc {
	cacheControl := func(r *http.Request) string {
		switch r.URL.Path {
		case rootTemplatePath:
			return "no-store"
		}
		return cacheMaxAge
	}
	return func(w http.ResponseWriter, r *http.Request) {
		if strings.Contains(r.Header.Get(HeaderAcceptEncoding), "gzip") {
			w2 := gzip.NewWriter(w)
			defer w2.Close()
			w = wrappedResponseWriter{
				Writer:         w2,
				ResponseWriter: w,
			}
			w.Header().Add(HeaderContentEncoding, "gzip")
		}
		w.Header().Set(HeaderCacheControl, cacheControl(r))
		w.Header().Set(HeaderStrictTransportSecurity, cacheMaxAge)
		addMimeType(r.URL.Path, w)
		h.ServeHTTP(w, r)
	}
}
// fileHandler wraps the handling of the file, add cache-control header and gzip compression, if possible.
fileHandler wraps the handling of the file, add cache-control header and gzip compression, if possible.
// fileHandler wraps the handling of the file add cache - control header and gzip compression if possible .
func fileHandler(h http.Handler, cacheMaxAge string) http.HandlerFunc {
	cacheControl := func(r *http.Request) string {
		switch r.URL.Path {
		case rootTemplatePath:
			return "no-store"
		}
		return cacheMaxAge
	}
	return func(w http.ResponseWriter, r *http.Request) {
		if strings.Contains(r.Header.Get(HeaderAcceptEncoding), "gzip") {
			w2 := gzip.NewWriter(w)
			defer w2.Close()
			w = wrappedResponseWriter{
				Writer:         w2,
				ResponseWriter: w,
			}
			w.Header().Add(HeaderContentEncoding, "gzip")
		}
		w.Header().Set(HeaderCacheControl, cacheControl(r))
		w.Header().Set(HeaderStrictTransportSecurity, cacheMaxAge)
		addMimeType(r.URL.Path, w)
		h.ServeHTTP(w, r)
	}
}
func fileHandler ( h http . Handler , cacheMaxAge string ) http . HandlerFunc { cacheControl := func ( r * http . Request ) string { switch r . URL . Path { case rootTemplatePath : return " " } return cacheMaxAge } return func ( w http . ResponseWriter , r * http . Request ) { if strings . Contains ( r . Header . Get ( HeaderAcceptEncoding ) , " " ) { w2 := gzip . NewWriter ( w ) defer w2 . Close ( ) w = wrappedResponseWriter { Writer : w2 , ResponseWriter : w , } w . Header ( ) . Add ( HeaderContentEncoding , " " ) } w . Header ( ) . Set ( HeaderCacheControl , cacheControl ( r ) ) w . Header ( ) . Set ( HeaderStrictTransportSecurity , cacheMaxAge ) addMimeType ( r . URL . Path , w ) h . ServeHTTP ( w , r ) } }
fileHandler wraps the handling of the file, add cache-control header and gzip compression, if possible.
fileHandler wraps the handling of the file add cache - control header and gzip compression if possible .