Files
uptimesebi/internal/web/web.go
T
Sebastian UnterschützandClaude Opus 5.5 d20225982a refactor: follow the google go style guide
Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00

35 lines
808 B
Go

// 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)
}
}