monorepo/website/src/views.go
ange 5a8cfc055d
All checks were successful
/ mirror (push) Successful in 5s
/ deploy (push) Successful in 49s
CI/CD auto deploy website (#4)
Co-authored-by: stcb <21@stcb.cc>
Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#4
Co-authored-by: ange <ange@yw5n.com>
Co-committed-by: ange <ange@yw5n.com>
2025-01-16 12:27:59 +00:00

30 lines
616 B
Go

package main
import (
"context"
"net/http"
"path/filepath"
)
func index(w http.ResponseWriter, r *http.Request) {
html(w, r.WithContext(
context.WithValue(r.Context(), URLParam{}, []string{"index"}),
))
}
func static(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path)
}
func css(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join("css", getParam(r, 0)))
}
func html(w http.ResponseWriter, r *http.Request) {
if t, found := TMPL[getParam(r, 0)]; found {
w.Write(t)
} else {
http.NotFound(w, r)
}
}