mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 09:55:36 +00:00
serve bundled index.html
This commit is contained in:
@@ -89,17 +89,22 @@ type ItemUpdateForm struct {
|
||||
}
|
||||
|
||||
func IndexHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
t := template.Must(template.New("index.html").Delims("{%", "%}").Funcs(template.FuncMap{
|
||||
"inline": func(svg string) template.HTML {
|
||||
if asset, ok := assets["graphicarts/" + svg]; ok {
|
||||
return template.HTML(*asset.text())
|
||||
}
|
||||
content, _ := ioutil.ReadFile("assets/graphicarts/" + svg)
|
||||
return template.HTML(content)
|
||||
},
|
||||
}).ParseFiles("assets/index.html"))
|
||||
rw.Header().Set("Content-Type", "text/html")
|
||||
t.Execute(rw, nil)
|
||||
if assets != nil {
|
||||
asset := assets["index.html"]
|
||||
|
||||
rw.Header().Set("Content-Type", "text/html")
|
||||
rw.Header().Set("Content-Encoding", "gzip")
|
||||
rw.Write(*asset.gzip())
|
||||
} else {
|
||||
t := template.Must(template.New("index.html").Delims("{%", "%}").Funcs(template.FuncMap{
|
||||
"inline": func(svg string) template.HTML {
|
||||
content, _ := ioutil.ReadFile("assets/graphicarts/" + svg)
|
||||
return template.HTML(content)
|
||||
},
|
||||
}).ParseFiles("assets/index.html"))
|
||||
rw.Header().Set("Content-Type", "text/html")
|
||||
t.Execute(rw, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func StaticHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
|
Reference in New Issue
Block a user