Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cabal flag to disable servant-auth #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion servant-reflex.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/Servant/Reflex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..),
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -623,3 +630,4 @@ type family HasCookieAuth xs :: Constraint where

class CookieAuthNotEnabled

#endif