示例#1
0
文件: webui.go 项目: n-boy/backuper
func getTemplateSrc(name string) string {
	data, err := base.Asset(name)
	if err != nil {
		base.LogErr.Fatalf("template file is not founded: %s\n", name)
	}
	return string(data)
}
示例#2
0
文件: webui.go 项目: n-boy/backuper
func staticHandler(w http.ResponseWriter, r *http.Request) {
	data, err := base.Asset("webui" + r.URL.Path)
	if err != nil {
		http.NotFound(w, r)
	}

	mimeType := mime.TypeByExtension(filepath.Ext(r.URL.Path))
	if mimeType != "" {
		w.Header().Add("Content-type", mimeType)
	}
	w.Write(data)
}