diff options
| author | haturatu <taro@eyes4you.org> | 2025-10-13 00:45:26 +0900 |
|---|---|---|
| committer | haturatu <taro@eyes4you.org> | 2025-10-13 00:45:26 +0900 |
| commit | 5fde794315efd7c8146e7b69b9e7d05132a2e3df (patch) | |
| tree | 741ee8f220e3b65374e5c67ed75700321249002f /middleware/auth.go | |
| parent | ff0668aa216c6645e2bb26e0a7ef5091a62a84ba (diff) | |
a
Diffstat (limited to 'middleware/auth.go')
| -rw-r--r-- | middleware/auth.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/middleware/auth.go b/middleware/auth.go index e4f096b..5025f32 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -154,4 +154,16 @@ func AdminMiddleware(next http.Handler) http.Handler { logging.SecurityLog.Info("ADMIN ACCESS GRANTED", "user", user.Username, "path", r.URL.Path, "ip", ip) next.ServeHTTP(w, r) }) +} + +// HandleOptions is a middleware that handles pre-flight OPTIONS requests. +// This should be placed before the CSRF middleware. +func HandleOptions(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodOptions { + w.WriteHeader(http.StatusOK) + return + } + next.ServeHTTP(w, r) + }) }
\ No newline at end of file |
