servant-auth-server 0.2.7.0 → 0.2.8.0
raw patch · 5 files changed
+37/−12 lines, 5 filesdep +taggeddep ~servant-servernew-uploader
Dependencies added: tagged
Dependency ranges changed: servant-server
Files
- package.yaml +3/−2
- servant-auth-server.cabal +8/−5
- src/Servant/Auth/Server/Internal/AddSetCookie.hs +9/−0
- src/Servant/Auth/Server/Internal/ThrowAll.hs +10/−2
- test/Servant/Auth/ServerSpec.hs +7/−3
package.yaml view
@@ -1,5 +1,5 @@ name: servant-auth-server-version: 0.2.7.0+version: 0.2.8.0 synopsis: servant-server/servant-auth compatibility description: | This package provides the required instances for using the @Auth@ combinator@@ -37,7 +37,7 @@ - jose >= 0.5 && < 0.6 - monad-time >= 0.2 && < 0.3 - time >= 1.5 && < 1.7- - servant-server >= 0.9.1 && < 0.11+ - servant-server >= 0.9.1 && < 0.12 - base64-bytestring >= 1 && < 2 - blaze-builder >= 0.4 && < 0.5 - unordered-containers >= 0.2 && < 0.3@@ -48,6 +48,7 @@ - data-default-class >= 0.0 && < 0.2 - http-api-data >= 0.3 && < 0.4 - http-types >= 0.9 && < 0.10+ - tagged >= 0.7.3 && < 0.9 default-extensions:
servant-auth-server.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.15.0.+-- This file has been generated from package.yaml by hpack version 0.17.0. -- -- see: https://github.com/sol/hpack name: servant-auth-server-version: 0.2.7.0+version: 0.2.8.0 synopsis: servant-server/servant-auth compatibility description: This package provides the required instances for using the @Auth@ combinator in your 'servant' server.@@ -48,7 +48,7 @@ , jose >= 0.5 && < 0.6 , monad-time >= 0.2 && < 0.3 , time >= 1.5 && < 1.7- , servant-server >= 0.9.1 && < 0.11+ , servant-server >= 0.9.1 && < 0.12 , base64-bytestring >= 1 && < 2 , blaze-builder >= 0.4 && < 0.5 , unordered-containers >= 0.2 && < 0.3@@ -59,6 +59,7 @@ , data-default-class >= 0.0 && < 0.2 , http-api-data >= 0.3 && < 0.4 , http-types >= 0.9 && < 0.10+ , tagged >= 0.7.3 && < 0.9 exposed-modules: Servant.Auth.Server Servant.Auth.Server.Internal@@ -93,7 +94,7 @@ , jose >= 0.5 && < 0.6 , monad-time >= 0.2 && < 0.3 , time >= 1.5 && < 1.7- , servant-server >= 0.9.1 && < 0.11+ , servant-server >= 0.9.1 && < 0.12 , base64-bytestring >= 1 && < 2 , blaze-builder >= 0.4 && < 0.5 , unordered-containers >= 0.2 && < 0.3@@ -104,6 +105,7 @@ , data-default-class >= 0.0 && < 0.2 , http-api-data >= 0.3 && < 0.4 , http-types >= 0.9 && < 0.10+ , tagged >= 0.7.3 && < 0.9 , servant-auth , servant-auth-server , servant-server@@ -132,7 +134,7 @@ , jose >= 0.5 && < 0.6 , monad-time >= 0.2 && < 0.3 , time >= 1.5 && < 1.7- , servant-server >= 0.9.1 && < 0.11+ , servant-server >= 0.9.1 && < 0.12 , base64-bytestring >= 1 && < 2 , blaze-builder >= 0.4 && < 0.5 , unordered-containers >= 0.2 && < 0.3@@ -143,6 +145,7 @@ , data-default-class >= 0.0 && < 0.2 , http-api-data >= 0.3 && < 0.4 , http-types >= 0.9 && < 0.10+ , tagged >= 0.7.3 && < 0.9 , servant-auth-server , hspec > 2 && < 3 , QuickCheck >= 2.8 && < 2.10
src/Servant/Auth/Server/Internal/AddSetCookie.hs view
@@ -7,6 +7,7 @@ import Blaze.ByteString.Builder (toByteString) import qualified Data.ByteString as BS+import Data.Tagged (Tagged (..)) import qualified Network.HTTP.Types as HTTP import Network.Wai (mapResponseHeaders) import Servant@@ -64,10 +65,18 @@ => AddSetCookies ('S n) (a :<|> b) (a' :<|> b') where addSetCookies cookies (a :<|> b) = addSetCookies cookies a :<|> addSetCookies cookies b +-- | for @servant <0.11@ instance AddSetCookies ('S n) Application Application where addSetCookies cookies r request respond = r request (\response -> respond+ $ mapResponseHeaders (++ mkHeaders cookies) response)++-- | for @servant >=0.11@+instance+ AddSetCookies ('S n) (Tagged m Application) (Tagged m Application) where+ addSetCookies cookies r = Tagged $ \request respond ->+ unTagged r request (\response -> respond $ mapResponseHeaders (++ mkHeaders cookies) response) mkHeaders :: SetCookieList x -> [HTTP.Header]
src/Servant/Auth/Server/Internal/ThrowAll.hs view
@@ -2,6 +2,7 @@ module Servant.Auth.Server.Internal.ThrowAll where import Control.Monad.Error.Class+import Data.Tagged (Tagged (..)) import Servant ((:<|>) (..), ServantErr(..)) import Network.HTTP.Types import Network.Wai@@ -22,15 +23,22 @@ -- Really this shouldn't be necessary - ((->) a) should be an instance of -- MonadError, no?-instance {-# OVERLAPS #-} ThrowAll b => ThrowAll (a -> b) where+instance {-# OVERLAPPING #-} ThrowAll b => ThrowAll (a -> b) where throwAll e = const $ throwAll e instance {-# OVERLAPPABLE #-} (MonadError ServantErr m) => ThrowAll (m a) where throwAll = throwError -instance {-# OVERLAPS #-} ThrowAll Application where+-- | for @servant <0.11@+instance {-# OVERLAPPING #-} ThrowAll Application where throwAll e _req respond = respond $ responseLBS (mkStatus (errHTTPCode e) (BS.pack $ errReasonPhrase e)) (errHeaders e) (errBody e) +-- | for @servant >=0.11@+instance {-# OVERLAPPING #-} MonadError ServantErr m => ThrowAll (Tagged m Application) where+ throwAll e = Tagged $ \_req respond ->+ respond $ responseLBS (mkStatus (errHTTPCode e) (BS.pack $ errReasonPhrase e))+ (errHeaders e)+ (errBody e)
test/Servant/Auth/ServerSpec.hs view
@@ -372,9 +372,13 @@ getHeaderInt :: Handler (Headers '[Header "Blah" Int] Int) getHeaderInt = return $ addHeader 1797 17 - raw :: Application- raw _req respond- = respond $ responseLBS status200 [("hi", "there")] "how are you?"+ raw :: Server Raw+ raw =+#if MIN_VERSION_servant_server(0,11,0)+ Tagged $+#endif+ \_req respond ->+ respond $ responseLBS status200 [("hi", "there")] "how are you?" -- }}} ------------------------------------------------------------------------------