establishing initial auth middleware and routes

This commit is contained in:
juancwu 2025-12-17 11:26:10 -05:00
commit 5c5ba78a32
6 changed files with 92 additions and 1 deletions

View file

@ -0,0 +1,14 @@
package middleware
import "net/http"
func Redirect(path string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("HX-Request") == "true" {
w.Header().Set("HX-Redirect", path)
w.WriteHeader(http.StatusSeeOther)
return
}
http.Redirect(w, r, path, http.StatusSeeOther)
})
}