Compare commits

..

2 Commits

Author SHA1 Message Date
bel 96052b786d accept .redir=true 2026-06-20 20:28:03 -06:00
bel 9189b97277 oop 2026-06-19 21:26:02 -06:00
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -22,6 +22,7 @@ type (
Endpoint struct { Endpoint struct {
To string To string
Redir bool
BasicAuth string BasicAuth string
} }
) )
+7 -2
View File
@@ -39,8 +39,15 @@ func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
if endpoint.Redir {
http.Redirect(w, r, r.URL.String(), http.StatusSeeOther)
return
}
cors(w) cors(w)
if r.Method == http.MethodOptions { if r.Method == http.MethodOptions {
w.Header().Set("Content-Length", "0")
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
return return
} }
@@ -75,8 +82,6 @@ func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func cors(w http.ResponseWriter) { func cors(w http.ResponseWriter) {
w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", "X-Auth-Token, content-type, Content-Type") w.Header().Set("Access-Control-Allow-Headers", "X-Auth-Token, content-type, Content-Type")
w.Header().Set("Content-Length", "0")
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS, TRACE, PATCH, HEAD, DELETE") w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS, TRACE, PATCH, HEAD, DELETE")
} }