Made servant-auth optional

This commit is contained in:
iko 2021-12-18 19:57:37 +03:00
parent f76dbeb941
commit 39d6ff2531
Signed by untrusted user: iko
GPG Key ID: 82C257048D1026F2
2 changed files with 18 additions and 2 deletions

View File

@ -15,6 +15,11 @@ Flag Example
description: Enable example description: Enable example
default: False default: False
Flag servant-auth
description: Enable servant-auth
default: True
manual: False
library library
exposed-modules: exposed-modules:
Servant.Common.BaseUrl Servant.Common.BaseUrl
@ -40,11 +45,14 @@ library
reflex-dom-core >= 0.6 && < 0.7, reflex-dom-core >= 0.6 && < 0.7,
safe >= 0.3.9 && < 0.4, safe >= 0.3.9 && < 0.4,
servant >= 0.16 && < 0.18, servant >= 0.16 && < 0.18,
servant-auth >= 0.2.1 && < 0.4,
string-conversions >= 0.4 && < 0.5, string-conversions >= 0.4 && < 0.5,
text >= 1.2 && < 1.3, text >= 1.2 && < 1.3,
transformers >= 0.4 && < 0.6 transformers >= 0.4 && < 0.6
if flag(servant-auth)
build-depends:
servant-auth >= 0.2.1 && < 0.4
ghc-options: -Wall -fwarn-tabs -funbox-strict-fields ghc-options: -Wall -fwarn-tabs -funbox-strict-fields
default-language: Haskell2010 default-language: Haskell2010

View File

@ -61,7 +61,6 @@ import Servant.API ((:<|>) (..), (:>), BasicAuth,
ToHttpApiData (..), Vault, Verb, ToHttpApiData (..), Vault, Verb,
contentType) contentType)
import Servant.API.Description (Summary) import Servant.API.Description (Summary)
import qualified Servant.Auth as Auth
import Reflex.Dom.Core (Dynamic, Event, Reflex, import Reflex.Dom.Core (Dynamic, Event, Reflex,
XhrRequest (..), XhrResponse (..), XhrRequest (..), XhrResponse (..),
@ -90,6 +89,11 @@ import Servant.Common.Req (ClientOptions(..),
reqTag, reqTag,
qParams, withCredentials) qParams, withCredentials)
#ifdef servant-auth
import qualified Servant.Auth as Auth
#endif
-- * Accessing APIs as a Client -- * Accessing APIs as a Client
@ -610,6 +614,9 @@ for empty and one for non-empty lists).
-- @HasCookieAuth auths@ is nominally a redundant constraint, but ensures -- @HasCookieAuth auths@ is nominally a redundant constraint, but ensures
-- we're not trying to rely on cookies when the API does not use them. -- we're not trying to rely on cookies when the API does not use them.
#ifdef servant-auth
instance (HasCookieAuth auths, HasClient t m api tag) => HasClient t m (Auth.Auth auths a :> api) tag where instance (HasCookieAuth auths, HasClient t m api tag) => HasClient t m (Auth.Auth auths a :> api) tag where
type Client t m (Auth.Auth auths a :> api) tag = Client t m api tag type Client t m (Auth.Auth auths a :> api) tag = Client t m api tag
@ -623,3 +630,4 @@ type family HasCookieAuth xs :: Constraint where
class CookieAuthNotEnabled class CookieAuthNotEnabled
#endif