added aggressive preflight middleware

This commit is contained in:
Yann Esposito 2015-08-05 10:03:10 +02:00
parent 82a0e3ad86
commit 17e9c6a4bc
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,4 @@
(defproject fuck-cors "0.1.5"
(defproject fuck-cors "0.1.6"
:description "Fuck CORS and open all to everyone"
:url "http://github.com/yogsototh/fuck-cors"
:license {:name "MIT"

View file

@ -33,3 +33,14 @@
"Vary" "Accept-Encoding, Origin, Accept-Language"}]
(-> (handler request)
(update-in [:headers] #(into % headers))))))
(defn wrap-preflight
"Add a preflight answer. Will break any OPTIONS handler, beware.
To put AFTER wrap-open-cors"
[handler]
(fn [request]
(if (= (request :request-method) :options)
(into request {:status 200 :body "preflight complete"})
(handler request))))