Servant.Client.Core.BaseUrl

servant-client-core-0.20.2: Core functionality and class for client function generation for servant APIs

Safe Haskell | None
Language | Haskell2010

Servant.Client.Core.BaseUrl

Synopsis

- data BaseUrl = BaseUrl {
  - baseUrlScheme :: Scheme
  - baseUrlHost :: String
  - baseUrlPort :: Int
  - baseUrlPath :: String
  }
- data Scheme
  - = Http
  - | Https
- showBaseUrl :: BaseUrl -> String
- parseBaseUrl :: MonadThrow m => String -> m BaseUrl
- newtype InvalidBaseUrlException = InvalidBaseUrlException String

# Documentation

data BaseUrl #

Simple data type to represent the target of HTTP requests for servant's automatically-generated clients.

Constructors

BaseUrl |
Fields baseUrlScheme :: Scheme URI scheme to use baseUrlHost :: String host (eg "haskell.org") baseUrlPort :: Int port (eg 80) baseUrlPath :: String path (eg "ab/c")

#### Instances

Instances details

FromJSON BaseUrl # |
    >>> parseBaseUrl "api.example.com" >>= decode . encode :: Maybe BaseUrl
    Just (BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""})
Instance details Defined in Servant.Client.Core.BaseUrl Methods parseJSON :: Value -> Parser BaseUrl # parseJSONList :: Value -> Parser [BaseUrl] # omittedField :: Maybe BaseUrl #
FromJSONKey BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods fromJSONKey :: FromJSONKeyFunction BaseUrl # fromJSONKeyList :: FromJSONKeyFunction [BaseUrl] #
ToJSON BaseUrl # |
    >>> traverse_ (LBS8.putStrLn . encode) (parseBaseUrl "api.example.com" :: [BaseUrl])
    "http://api.example.com"
Instance details Defined in Servant.Client.Core.BaseUrl Methods toJSON :: BaseUrl -> Value # toEncoding :: BaseUrl -> Encoding # toJSONList :: [BaseUrl] -> Value # toEncodingList :: [BaseUrl] -> Encoding # omitField :: BaseUrl -> Bool #
ToJSONKey BaseUrl # |
    >>> :{
    traverse_ (LBS8.putStrLn . encode) $ do
      u1 <- parseBaseUrl "api.example.com" :: [BaseUrl]
      u2 <- parseBaseUrl "example.com" :: [BaseUrl]
      return $ Map.fromList [(u1, 'x'), (u2, 'y')]
    :}
    {"http://api.example.com":"x","http://example.com":"y"}
Instance details Defined in Servant.Client.Core.BaseUrl Methods toJSONKey :: ToJSONKeyFunction BaseUrl # toJSONKeyList :: ToJSONKeyFunction [BaseUrl] #
NFData BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods rnf :: BaseUrl -> () #
Data BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BaseUrl -> c BaseUrl # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BaseUrl # toConstr :: BaseUrl -> Constr # dataTypeOf :: BaseUrl -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BaseUrl) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BaseUrl) # gmapT :: (forall b. Data b => b -> b) -> BaseUrl -> BaseUrl # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r # gmapQ :: (forall d. Data d => d -> u) -> BaseUrl -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BaseUrl -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl #
Generic BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Associated Types
type Rep BaseUrl |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep BaseUrl = D1 ('MetaData "BaseUrl" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "BaseUrl" 'PrefixI 'True) ((S1 ('MetaSel ('Just "baseUrlScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Scheme) :*: S1 ('MetaSel ('Just "baseUrlHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :*: (S1 ('MetaSel ('Just "baseUrlPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "baseUrlPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))
Methods from :: BaseUrl -> Rep BaseUrl x # to :: Rep BaseUrl x -> BaseUrl #
Show BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> BaseUrl -> ShowS # show :: BaseUrl -> String # showList :: [BaseUrl] -> ShowS #
Eq BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: BaseUrl -> BaseUrl -> Bool # (/=) :: BaseUrl -> BaseUrl -> Bool #
Ord BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: BaseUrl -> BaseUrl -> Ordering # (<) :: BaseUrl -> BaseUrl -> Bool # (<=) :: BaseUrl -> BaseUrl -> Bool # (>) :: BaseUrl -> BaseUrl -> Bool # (>=) :: BaseUrl -> BaseUrl -> Bool # max :: BaseUrl -> BaseUrl -> BaseUrl # min :: BaseUrl -> BaseUrl -> BaseUrl #
Lift BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => BaseUrl -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => BaseUrl -> Code m BaseUrl #
type Rep BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep BaseUrl = D1 ('MetaData "BaseUrl" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "BaseUrl" 'PrefixI 'True) ((S1 ('MetaSel ('Just "baseUrlScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Scheme) :*: S1 ('MetaSel ('Just "baseUrlHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :*: (S1 ('MetaSel ('Just "baseUrlPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "baseUrlPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))

data Scheme #

URI scheme to use

Constructors

Http | http://
Https | https://

#### Instances

Instances details

Data Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Scheme -> c Scheme # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Scheme # toConstr :: Scheme -> Constr # dataTypeOf :: Scheme -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Scheme) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scheme) # gmapT :: (forall b. Data b => b -> b) -> Scheme -> Scheme # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r # gmapQ :: (forall d. Data d => d -> u) -> Scheme -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Scheme -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme #
Generic Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Associated Types
type Rep Scheme |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep Scheme = D1 ('MetaData "Scheme" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: Scheme -> Rep Scheme x # to :: Rep Scheme x -> Scheme #
Show Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> Scheme -> ShowS # show :: Scheme -> String # showList :: [Scheme] -> ShowS #
Eq Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: Scheme -> Scheme -> Bool # (/=) :: Scheme -> Scheme -> Bool #
Ord Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: Scheme -> Scheme -> Ordering # (<) :: Scheme -> Scheme -> Bool # (<=) :: Scheme -> Scheme -> Bool # (>) :: Scheme -> Scheme -> Bool # (>=) :: Scheme -> Scheme -> Bool # max :: Scheme -> Scheme -> Scheme # min :: Scheme -> Scheme -> Scheme #
Lift Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => Scheme -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => Scheme -> Code m Scheme #
type Rep Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep Scheme = D1 ('MetaData "Scheme" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))

showBaseUrl :: BaseUrl -> String #

    >>> showBaseUrl <$> parseBaseUrl "api.example.com"
    "http://api.example.com"

parseBaseUrl :: MonadThrow m => String -> m BaseUrl #

    >>> parseBaseUrl "api.example.com"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""}

Note: trailing slash is removed

    >>> parseBaseUrl "api.example.com/"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""}

    >>> parseBaseUrl "api.example.com/dir/"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = "/dir"}

newtype InvalidBaseUrlException #

Constructors

InvalidBaseUrlException String |

#### Instances

Instances details

Exception InvalidBaseUrlException # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods toException :: InvalidBaseUrlException -> SomeException # fromException :: SomeException -> Maybe InvalidBaseUrlException # displayException :: InvalidBaseUrlException -> String # backtraceDesired :: InvalidBaseUrlException -> Bool #
Show InvalidBaseUrlException # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> InvalidBaseUrlException -> ShowS # show :: InvalidBaseUrlException -> String # showList :: [InvalidBaseUrlException] -> ShowS #