Files
spend-sparrow/service/static_ui.go

26 lines
531 B
Go

package service
import (
"database/sql"
"me-fit/template"
"net/http"
"github.com/a-h/templ"
)
func HandleIndexAnd404(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var comp templ.Component = nil
userComp := UserInfoComp(verifySessionAndReturnUser(db, r))
if r.URL.Path != "/" {
comp = template.Layout(template.NotFound(), userComp)
w.WriteHeader(http.StatusNotFound)
} else {
comp = template.Layout(template.Index(), userComp)
}
comp.Render(r.Context(), w)
}
}