diff --git a/servant-reflex.cabal b/servant-reflex.cabal index 8ee8ff8..6e18539 100644 --- a/servant-reflex.cabal +++ b/servant-reflex.cabal @@ -15,6 +15,11 @@ Flag Example description: Enable example default: False +Flag servant-auth + description: Enable servant-auth + default: True + manual: False + library exposed-modules: Servant.Common.BaseUrl @@ -40,11 +45,14 @@ library reflex-dom-core >= 0.6 && < 0.7, safe >= 0.3.9 && < 0.4, servant >= 0.16 && < 0.18, - servant-auth >= 0.2.1 && < 0.4, string-conversions >= 0.4 && < 0.5, text >= 1.2 && < 1.3, 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 default-language: Haskell2010 diff --git a/src/Servant/Reflex.hs b/src/Servant/Reflex.hs index d972497..445900e 100644 --- a/src/Servant/Reflex.hs +++ b/src/Servant/Reflex.hs @@ -61,7 +61,6 @@ import Servant.API ((:<|>) (..), (:>), BasicAuth, ToHttpApiData (..), Vault, Verb, contentType) import Servant.API.Description (Summary) -import qualified Servant.Auth as Auth import Reflex.Dom.Core (Dynamic, Event, Reflex, XhrRequest (..), XhrResponse (..), @@ -90,6 +89,11 @@ import Servant.Common.Req (ClientOptions(..), reqTag, qParams, withCredentials) +#ifdef servant-auth + +import qualified Servant.Auth as Auth + +#endif -- * 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 -- 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 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 +#endif \ No newline at end of file