go-sample-webpage/pkg/dashboard/dashboard.go
kekskurse 360ee1c5fe
Some checks failed
continuous-integration/drone/push Build is failing
stuff
2021-11-25 01:32:48 +01:00

32 lines
No EOL
661 B
Go

package dashboard
import (
"embed"
"github.com/go-chi/chi/v5"
"github.com/unrolled/render"
"net/http"
)
// content holds our static web server content.
//go:embed templates/*
var webserver embed.FS
var ren *render.Render
func Register(router chi.Router, template func(http.Handler) http.Handler) {
ren = render.New(render.Options{
//Layout: "layout",
FileSystem: &render.EmbedFileSystem{
FS: webserver,
},
})
router.Group(func(r chi.Router) {
r.Use(template)
r.Get("/dashboard", sampleCall)
})
}
func sampleCall(w http.ResponseWriter, r *http.Request) {
ren.HTML(w, http.StatusOK, "dashboard", map[string]string {"title": "World"})
}