// Package web contains the templ components and static assets shared by // the console and status pages. package web import ( "embed" "io/fs" "net/http" "github.com/a-h/templ" "github.com/gin-gonic/gin" ) //go:embed all:static var static embed.FS // Static serves the embedded build output of npm run build. func Static() http.FileSystem { sub, err := fs.Sub(static, "static") if err != nil { panic(err) } return http.FS(sub) } // Render writes comp as HTML. Rendering errors are attached to c so the // access log records them; the status has already been sent. func Render(c *gin.Context, status int, comp templ.Component) { c.Status(status) c.Header("Content-Type", "text/html; charset=utf-8") if err := comp.Render(c.Request.Context(), c.Writer); err != nil { _ = c.Error(err) } }