establishing initial auth middleware and routes
This commit is contained in:
parent
f251f52fa9
commit
5c5ba78a32
6 changed files with 92 additions and 1 deletions
14
internal/middleware/redirect.go
Normal file
14
internal/middleware/redirect.go
Normal 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)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue