feat: added API gateway

This commit is contained in:
ITQ
2025-12-17 11:00:50 +03:00
parent daa8c24482
commit 340ae43d22
30 changed files with 2838 additions and 3 deletions
+21
View File
@@ -0,0 +1,21 @@
package middleware
import (
"net/http"
)
func CORSMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
w.Header().Set("Access-Control-Max-Age", "3600")
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
next.ServeHTTP(w, r)
})
}