go-sample-webpage/pkg/sample/sample.go

29 lines
554 B
Go
Raw Normal View History

2021-11-03 01:10:36 +00:00
package sample
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) {
ren = render.New(render.Options{
//Layout: "layout",
FileSystem: &render.EmbedFileSystem{
FS: webserver,
},
})
router.Get("/sample", sampleCall)
}
func sampleCall(w http.ResponseWriter, r *http.Request) {
ren.HTML(w, http.StatusOK, "ssp", map[string]string {"title": "World"})
}