{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module Blockfrost.Client.UserAgent () where
import Blockfrost.Util.UserAgent
import Data.CaseInsensitive (mk)
import Data.Proxy (Proxy (..))
import Data.Sequence ((<|))
import Servant.API ((:>))
import Servant.Client.Core (Client, HasClient (..), requestHeaders)
instance {-# OVERLAPS #-} (HasClient m api) => HasClient m (UserAgent :> api) where
type Client m (UserAgent :> api) = Client m api
clientWithRoute :: Proxy m
-> Proxy (UserAgent :> api)
-> Request
-> Client m (UserAgent :> api)
clientWithRoute Proxy m
m Proxy (UserAgent :> api)
_ Request
req
= Proxy m -> Proxy api -> Request -> Client m api
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
m (Proxy api
forall k (t :: k). Proxy t
Proxy :: Proxy api)
(Request -> Client m api) -> Request -> Client m api
forall a b. (a -> b) -> a -> b
$ Request
req { requestHeaders :: Seq Header
requestHeaders = (ByteString -> CI ByteString
forall s. FoldCase s => s -> CI s
mk ByteString
"User-Agent", ByteString
userAgent) Header -> Seq Header -> Seq Header
forall a. a -> Seq a -> Seq a
<| Request -> Seq Header
forall body path. RequestF body path -> Seq Header
requestHeaders Request
req }
hoistClientMonad :: Proxy m
-> Proxy (UserAgent :> api)
-> (forall x. mon x -> mon' x)
-> Client mon (UserAgent :> api)
-> Client mon' (UserAgent :> api)
hoistClientMonad Proxy m
pm Proxy (UserAgent :> api)
_ forall x. mon x -> mon' x
nt = Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy api
forall k (t :: k). Proxy t
Proxy :: Proxy api) forall x. mon x -> mon' x
nt