Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
30 lines
506 B
Go
30 lines
506 B
Go
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
|
|
|
|
func Static() http.FileSystem {
|
|
sub, err := fs.Sub(static, "static")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return http.FS(sub)
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|