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