@@ -1,6 +1,7 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
@@ -8,7 +9,7 @@ module Cors
8import qualified Data.HashSet as HashSet
9import qualified Data.HashSet as HashSet
9import Network.URI (parseURI)
10import Network.URI (parseURI)
10import Snap.Core (Snap, Method, method)
11import Snap.Core (Snap, Method, method)
11−import Snap.Util.CORS (CORSOptions(..), HashableMethod(..), OriginList(Origins), applyCORS, mkOriginSet)
12+import Snap.Util.CORS (CORSOptions(..), HashableMethod(..), OriginList(..), applyCORS, mkOriginSet)
@@ -17,7 +18,15 @@ import Snap.Util.CORS (CORSOptions(..), HashableMethod(..), OriginList(Origins),
18allow :: Method -> [String] -> Snap () -> Snap ()
19allow :: Method -> [String] -> Snap () -> Snap ()
19allow method_ origins snap =
20allow method_ origins snap =
20− applyCORS (toOptions method_ origins) $ method method_ $
21+ applyCORS (toOptions method_ (toOriginList origins)) $
26+open :: Method -> Snap () -> Snap ()
28+ applyCORS (toOptions method_ Everywhere) $
@@ -25,10 +34,9 @@ allow method_ origins snap =
25-- TO OPTIONS
34-- TO OPTIONS
28−toOptions :: (Monad m) => Method -> [String] -> CORSOptions m
37+toOptions :: (Monad m) => Method -> OriginList -> CORSOptions m
29−toOptions method_ origins =
38+toOptions method_ allowedOrigins =
31− allowedOrigins = toOriginList origins
32 allowedMethods = HashSet.singleton (HashableMethod method_)
40 allowedMethods = HashSet.singleton (HashableMethod method_)
34 CORSOptions
42 CORSOptions