servant-client-core-0.20.3.0: 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 Source #

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 Source #

    >>> 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 Source # parseJSONList :: Value -> Parser [BaseUrl] Source # omittedField :: Maybe BaseUrl Source #
FromJSONKey BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods fromJSONKey :: FromJSONKeyFunction BaseUrl Source # fromJSONKeyList :: FromJSONKeyFunction [BaseUrl] Source #

ToJSON BaseUrl Source #

    >>> 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 Source # toEncoding :: BaseUrl -> Encoding Source # toJSONList :: [BaseUrl] -> Value Source # toEncodingList :: [BaseUrl] -> Encoding Source # omitField :: BaseUrl -> Bool Source #

ToJSONKey BaseUrl Source #

    >>> :{
    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 Source # toJSONKeyList :: ToJSONKeyFunction [BaseUrl] Source #
NFData BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods rnf :: BaseUrl -> () Source #
Data BaseUrl Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BaseUrl Source #

toConstr :: BaseUrl -> Constr Source #

dataTypeOf :: BaseUrl -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BaseUrl) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BaseUrl) Source #

gmapT :: (forall b. Data b => b -> b) -> BaseUrl -> BaseUrl Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> BaseUrl -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BaseUrl -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl Source #

Generic BaseUrl Source # |

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.3.0-8S9QaOrR0pTLkHAcl21Dlv" '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 Source #

to :: Rep BaseUrl x -> BaseUrl Source #

Show BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> BaseUrl -> ShowS Source # show :: BaseUrl -> String Source # showList :: [BaseUrl] -> ShowS Source #
Eq BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: BaseUrl -> BaseUrl -> Bool Source # (/=) :: BaseUrl -> BaseUrl -> Bool Source #
Ord BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: BaseUrl -> BaseUrl -> Ordering Source # (<) :: BaseUrl -> BaseUrl -> Bool Source # (<=) :: BaseUrl -> BaseUrl -> Bool Source # (>) :: BaseUrl -> BaseUrl -> Bool Source # (>=) :: BaseUrl -> BaseUrl -> Bool Source # max :: BaseUrl -> BaseUrl -> BaseUrl Source # min :: BaseUrl -> BaseUrl -> BaseUrl Source #
Lift BaseUrl Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => BaseUrl -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => BaseUrl -> Code m BaseUrl Source #
type Rep BaseUrl Source # |

Instance details

Defined in Servant.Client.Core.BaseUrl

type Rep BaseUrl = D1 ('MetaData "BaseUrl" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" '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 Source #

URI scheme to use

Constructors

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

#### Instances

Instances details

Data Scheme Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Scheme Source #

toConstr :: Scheme -> Constr Source #

dataTypeOf :: Scheme -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Scheme) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scheme) Source #

gmapT :: (forall b. Data b => b -> b) -> Scheme -> Scheme Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Scheme -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Scheme -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme Source #

Generic Scheme Source # |

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.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: Scheme -> Rep Scheme x Source #

to :: Rep Scheme x -> Scheme Source #

Show Scheme Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> Scheme -> ShowS Source # show :: Scheme -> String Source # showList :: [Scheme] -> ShowS Source #
Eq Scheme Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: Scheme -> Scheme -> Bool Source # (/=) :: Scheme -> Scheme -> Bool Source #
Ord Scheme Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: Scheme -> Scheme -> Ordering Source # (<) :: Scheme -> Scheme -> Bool Source # (<=) :: Scheme -> Scheme -> Bool Source # (>) :: Scheme -> Scheme -> Bool Source # (>=) :: Scheme -> Scheme -> Bool Source # max :: Scheme -> Scheme -> Scheme Source # min :: Scheme -> Scheme -> Scheme Source #
Lift Scheme Source # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => Scheme -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Scheme -> Code m Scheme Source #
type Rep Scheme Source # |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep Scheme = D1 ('MetaData "Scheme" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))

showBaseUrl :: BaseUrl -> String Source #

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

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

    >>> 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 Source #

Constructors

InvalidBaseUrlException String |

#### Instances

Instances details

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