feat(api): add card-to-iban HTTP endpoint
This commit is contained in:
25
backend/internal/httpapi/cors.go
Normal file
25
backend/internal/httpapi/cors.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package httpapi
|
||||
|
||||
import "net/http"
|
||||
|
||||
func AllowOrigin(
|
||||
origin string,
|
||||
next http.Handler,
|
||||
) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Vary", "Origin")
|
||||
|
||||
if r.Header.Get("Origin") == origin {
|
||||
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
|
||||
|
||||
if r.Method == http.MethodOptions {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user