func serveAsset(path string, assetPath string, maxAgeSeconds int) { registerGzipHandler(path, func(w http.ResponseWriter, r *http.Request) { assetInfo, err := assets.AssetInfo(assetPath) if err != nil { panic(err) } if maxAgeSeconds != nocache { w.Header().Add(cacheControl, fmt.Sprintf("max-age=%d", maxAgeSeconds)) } http.ServeContent(w, r, assetInfo.Name(), assetInfo.ModTime(), bytes.NewReader(assets.MustAsset(assetPath))) }) }
func templateFromAsset(assetPath, templateName string) *template.Template { bytes := assets.MustAsset(assetPath) return template.Must(template.New(templateName).Funcs(funcMap).Parse(string(bytes))) }