really poor templ attempt
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

This commit is contained in:
2024-09-13 17:13:21 +10:00
parent 49ddd56e3d
commit b63e4482b7
8 changed files with 86 additions and 187 deletions

View File

@@ -2,16 +2,20 @@ package handler
import (
"context"
"github.com/a-h/templ"
"vctp/db"
"log/slog"
"net/http"
"vctp/db"
"github.com/a-h/templ"
)
// Handler handles requests.
type Handler struct {
Logger *slog.Logger
Database db.Database
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) {

View File

@@ -2,11 +2,17 @@ package handler
import (
"net/http"
"vctp/components/core"
"vctp/components/home"
)
// Home handles the home page.
func (h *Handler) Home(w http.ResponseWriter, r *http.Request) {
h.html(r.Context(), w, http.StatusOK, core.HTML("Example Site", home.Home()))
//h.html(r.Context(), w, http.StatusOK, core.HTML("Example Site", home.Home()))
// Render the template
err := home.Home(h.BuildTime, h.SHA1Ver, h.GoVersion).Render(r.Context(), w)
if err != nil {
http.Error(w, "Failed to render template", http.StatusInternalServerError)
}
}