Files
vctp2/server/handler/handler.go
Nathan Coad b63e4482b7
Some checks failed
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is failing
really poor templ attempt
2024-09-13 17:13:21 +10:00

29 lines
547 B
Go

package handler
import (
"context"
"log/slog"
"net/http"
"vctp/db"
"github.com/a-h/templ"
)
// Handler handles requests.
type Handler struct {
Logger *slog.Logger
Database db.Database
BuildTime string
SHA1Ver string
GoVersion string
}
func (h *Handler) html(ctx context.Context, w http.ResponseWriter, status int, t templ.Component) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(status)
if err := t.Render(ctx, w); err != nil {
h.Logger.Error("Failed to render component", "error", err)
}
}