blob: 9c02d61deba285d9658e746d0032d3c650b90c85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package glance
import (
"log/slog"
"net/http"
"github.com/a-h/templ"
"within.website/x/cmd/mi/models"
)
//go:generate go tool templ generate
func New(dao *models.DAO) *Glance {
return &Glance{dao: dao}
}
type Glance struct {
dao *models.DAO
}
func (g *Glance) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Widget-Title", "Who is front?")
w.Header().Add("Widget-Content-Type", "html")
sw, err := g.dao.WhoIsFront(r.Context())
if err != nil {
slog.Error("can't query front", "err", err)
templ.Handler(ohNoes(err), templ.WithStatus(http.StatusInternalServerError)).ServeHTTP(w, r)
return
}
templ.Handler(whoIsFront(sw)).ServeHTTP(w, r)
}
|