Simplified sending HTMX

This commit is contained in:
Caleb Gardner
2024-11-01 11:46:07 -05:00
parent 6925ff9e0c
commit 0f2b0f4f5d
4 changed files with 12 additions and 21 deletions
+7
View File
@@ -17,6 +17,13 @@ const (
)
func sendContent(w http.ResponseWriter, r *http.Request, content string, title string, favicon string) {
if title == "" {
title = "Darkstorm.tech"
}
if r.Header.Get("Hx-Request") == "true" {
w.Write([]byte("<title>" + title + "</title>" + content))
return
}
if r.URL.Query().Get("contentOnly") == "true" {
json.NewEncoder(w).Encode(map[string]string{"content": content, "title": title, "favicon": favicon})
return