Skip to content

Commit

Permalink
support servant-0.16, release 0.2.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanueltouzery committed Mar 1, 2019
1 parent ce278d5 commit 74fb35a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions slack-web.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: slack-web
version: 0.2.0.10
version: 0.2.0.11

build-type: Simple
cabal-version: 1.20
Expand Down Expand Up @@ -50,9 +50,9 @@ library
, http-api-data >= 0.3 && < 0.5
, http-client >= 0.5 && < 0.7
, http-client-tls >= 0.3 && < 0.4
, servant >= 0.12 && < 0.16
, servant-client >= 0.12 && < 0.16
, servant-client-core >= 0.12 && < 0.16
, servant >= 0.12 && < 0.17
, servant-client >= 0.12 && < 0.17
, servant-client-core >= 0.12 && < 0.17
, text >= 1.2 && < 1.3
, transformers
, mtl
Expand Down
13 changes: 10 additions & 3 deletions src/Web/Slack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ import Servant.API

-- servant-client
import Servant.Client hiding (Response, baseUrl)
import Servant.Client.Core (Request, appendToQueryString, ServantError)
import Servant.Client.Core.Internal.Auth
import Servant.Client.Core (Request, appendToQueryString)

-- slack-web
import qualified Web.Slack.Api as Api
Expand All @@ -87,6 +86,14 @@ mkClientEnv :: Manager -> BaseUrl -> ClientEnv
mkClientEnv = ClientEnv
#endif

#if MIN_VERSION_servant(0,16,0)
import Servant.Client.Core (AuthenticatedRequest, AuthClientData, mkAuthenticatedRequest, ClientError)
#else
import Servant.Client.Core.Internal.Auth
import Servant.Client.Core (ServantError)
type ClientError = ServantError
#endif

class HasManager a where
getManager :: a -> Manager

Expand Down Expand Up @@ -555,7 +562,7 @@ mkSlackAuthenticateReq :: (MonadReader env m, HasToken env)
=> m (AuthenticatedRequest (AuthProtect "token"))
mkSlackAuthenticateReq = flip mkAuthenticatedRequest authenticateReq . getToken <$> ask

unnestErrors :: Either ServantError (ResponseJSON a) -> Response a
unnestErrors :: Either ClientError (ResponseJSON a) -> Response a
unnestErrors (Right (ResponseJSON (Right a))) = Right a
unnestErrors (Right (ResponseJSON (Left (ResponseSlackError serv))))
= Left (Common.SlackError serv)
Expand Down
6 changes: 5 additions & 1 deletion src/Web/Slack/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE CPP #-}

----------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -52,6 +53,9 @@ import Web.Slack.Util
-- text
import Data.Text (Text)

#if !MIN_VERSION_servant(0,16,0)
type ClientError = ServantError
#endif

-- |
--
Expand Down Expand Up @@ -138,7 +142,7 @@ $(deriveFromJSON (jsonOpts "historyRsp") ''HistoryRsp)
-- |
-- Errors that can be triggered by a slack request.
data SlackClientError
= ServantError ServantError
= ServantError ClientError
-- ^ errors from the network connection
| SlackError Text
-- ^ errors returned by the slack API
Expand Down

0 comments on commit 74fb35a

Please sign in to comment.