Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96052b786d | ||
|
|
9189b97277 |
@@ -22,6 +22,7 @@ type (
|
||||
|
||||
Endpoint struct {
|
||||
To string
|
||||
Redir bool
|
||||
BasicAuth string
|
||||
}
|
||||
)
|
||||
|
||||
@@ -39,8 +39,15 @@ func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if endpoint.Redir {
|
||||
http.Redirect(w, r, r.URL.String(), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
cors(w)
|
||||
if r.Method == http.MethodOptions {
|
||||
w.Header().Set("Content-Length", "0")
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
@@ -75,8 +82,6 @@ func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
func cors(w http.ResponseWriter) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user