github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/routers/web/static.go (about) 1 package web 2 3 import ( 4 "bytes" 5 "html/template" 6 "io/ioutil" 7 8 "github.com/covergates/covergates/config" 9 "github.com/covergates/covergates/web" 10 "github.com/gin-gonic/gin" 11 ) 12 13 // HandleIndex return HTML 14 func HandleIndex(config *config.Config) gin.HandlerFunc { 15 return func(c *gin.Context) { 16 buffer := bytes.NewBuffer([]byte{}) 17 html := web.MustLookup("/index.html") 18 t, _ := template.New("index").Parse(string(html)) 19 t.Execute(buffer, config.Server.Base) 20 data, _ := ioutil.ReadAll(buffer) 21 c.Data(200, "text/html; charset=UTF-8", data) 22 } 23 }