Discover books, shows, and movies at your level. Track your progress by filling your Shelf with what you find, and share with other language learners. *No dusting required.
shlf.space
1package htmx
2
3import (
4 "fmt"
5 "net/http"
6)
7
8func HxNotice(w http.ResponseWriter, id, msg string) {
9 html := fmt.Sprintf(`<span id="%s" hx-swap-oob="innerHTML">%s</span>`, id, msg)
10 w.Header().Set("Content-Type", "text/html")
11 w.WriteHeader(http.StatusOK)
12 w.Write([]byte(html))
13}
14
15func HxError(w http.ResponseWriter, status int, msg string) {
16 w.WriteHeader(status)
17 w.Write([]byte(msg))
18}
19
20func HxRedirect(w http.ResponseWriter, status int, location string) {
21 w.Header().Set("HX-Redirect", location)
22 w.WriteHeader(status)
23}