@@ -1,6 +1,9 @@
1{-# LANGUAGE DeriveGeneric #-}
1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE ViewPatterns #-}
2{-# LANGUAGE ViewPatterns #-}
3−module Servant.Common.BaseUrl where
3+module Servant.Common.BaseUrl
5import Data.List
8import Data.List
6import GHC.Generics
9import GHC.Generics
@@ -8,15 +11,19 @@ import Network.URI
8import Safe
11import Safe
9import Text.Read
12import Text.Read
14+-- | URI scheme to use
11−data Scheme = Http | Https
15+data Scheme =
17+ | Https -- ^ https://
12 deriving (Show, Eq, Ord, Generic)
18 deriving (Show, Eq, Ord, Generic)
20+-- | Simple data type to represent the target of HTTP requests
21+-- for servant's automatically-generated clients.
14−data BaseUrl = BaseUrl {
22+data BaseUrl = BaseUrl
15− baseUrlScheme :: Scheme,
23+ { baseUrlScheme :: Scheme -- ^ URI scheme to use
16− baseUrlHost :: String,
24+ , baseUrlHost :: String -- ^ host (eg "haskell.org")
17− baseUrlPort :: Int
25+ , baseUrlPort :: Int -- ^ port (eg 80)
19− deriving (Show, Eq, Ord, Generic)
26+ } deriving (Show, Eq, Ord, Generic)
21showBaseUrl :: BaseUrl -> String
28showBaseUrl :: BaseUrl -> String
22showBaseUrl (BaseUrl urlscheme host port) =
29showBaseUrl (BaseUrl urlscheme host port) =