module Network.Gemini.Capsule.Types (
GemURL (..),
GemRequest (..),
GemResponse (..),
GemHandler,
GemCapSettings (..),
newGemURL,
newGemRequest,
newGemResponse,
newGemCapSettings
) where
import qualified Data.ByteString.Lazy as BSL
import Data.Word (Word8, Word16, Word32)
import Data.X509 (Certificate)
data GemURL = GemURL
{ GemURL -> String
gemHost :: String
, GemURL -> Maybe Word32
gemPort :: Maybe Word32
, GemURL -> [String]
gemPath :: [String]
, GemURL -> Maybe String
gemQuery :: Maybe String
} deriving (GemURL -> GemURL -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GemURL -> GemURL -> Bool
$c/= :: GemURL -> GemURL -> Bool
== :: GemURL -> GemURL -> Bool
$c== :: GemURL -> GemURL -> Bool
Eq, Int -> GemURL -> ShowS
[GemURL] -> ShowS
GemURL -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GemURL] -> ShowS
$cshowList :: [GemURL] -> ShowS
show :: GemURL -> String
$cshow :: GemURL -> String
showsPrec :: Int -> GemURL -> ShowS
$cshowsPrec :: Int -> GemURL -> ShowS
Show)
data GemRequest = GemRequest
{ GemRequest -> GemURL
reqURL :: GemURL
, GemRequest -> Maybe Certificate
reqCert :: Maybe Certificate
} deriving (GemRequest -> GemRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GemRequest -> GemRequest -> Bool
$c/= :: GemRequest -> GemRequest -> Bool
== :: GemRequest -> GemRequest -> Bool
$c== :: GemRequest -> GemRequest -> Bool
Eq, Int -> GemRequest -> ShowS
[GemRequest] -> ShowS
GemRequest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GemRequest] -> ShowS
$cshowList :: [GemRequest] -> ShowS
show :: GemRequest -> String
$cshow :: GemRequest -> String
showsPrec :: Int -> GemRequest -> ShowS
$cshowsPrec :: Int -> GemRequest -> ShowS
Show)
data GemResponse = GemResponse
{ GemResponse -> Word8
respStatus :: Word8
, GemResponse -> String
respMeta :: String
, GemResponse -> Maybe ByteString
respBody :: Maybe BSL.ByteString
} deriving (GemResponse -> GemResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GemResponse -> GemResponse -> Bool
$c/= :: GemResponse -> GemResponse -> Bool
== :: GemResponse -> GemResponse -> Bool
$c== :: GemResponse -> GemResponse -> Bool
Eq, Int -> GemResponse -> ShowS
[GemResponse] -> ShowS
GemResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GemResponse] -> ShowS
$cshowList :: [GemResponse] -> ShowS
show :: GemResponse -> String
$cshow :: GemResponse -> String
showsPrec :: Int -> GemResponse -> ShowS
$cshowsPrec :: Int -> GemResponse -> ShowS
Show)
type GemHandler = GemRequest -> IO GemResponse
data GemCapSettings = GemCapSettings
{ GemCapSettings -> Int
capConnections :: Int
, GemCapSettings -> Word16
capPort :: Word16
, GemCapSettings -> String
capCert :: FilePath
, GemCapSettings -> [String]
capCertChain :: [FilePath]
, GemCapSettings -> String
capKey :: FilePath
} deriving (GemCapSettings -> GemCapSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GemCapSettings -> GemCapSettings -> Bool
$c/= :: GemCapSettings -> GemCapSettings -> Bool
== :: GemCapSettings -> GemCapSettings -> Bool
$c== :: GemCapSettings -> GemCapSettings -> Bool
Eq, Int -> GemCapSettings -> ShowS
[GemCapSettings] -> ShowS
GemCapSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GemCapSettings] -> ShowS
$cshowList :: [GemCapSettings] -> ShowS
show :: GemCapSettings -> String
$cshow :: GemCapSettings -> String
showsPrec :: Int -> GemCapSettings -> ShowS
$cshowsPrec :: Int -> GemCapSettings -> ShowS
Show)
newGemURL
:: String
-> GemURL
newGemURL :: String -> GemURL
newGemURL String
host = GemURL
{ gemHost :: String
gemHost = String
host
, gemPort :: Maybe Word32
gemPort = forall a. Maybe a
Nothing
, gemPath :: [String]
gemPath = []
, gemQuery :: Maybe String
gemQuery = forall a. Maybe a
Nothing
}
newGemRequest
:: GemURL
-> GemRequest
newGemRequest :: GemURL -> GemRequest
newGemRequest GemURL
url = GemRequest
{ reqURL :: GemURL
reqURL = GemURL
url
, reqCert :: Maybe Certificate
reqCert = forall a. Maybe a
Nothing
}
newGemResponse :: GemResponse
newGemResponse :: GemResponse
newGemResponse = GemResponse
{ respStatus :: Word8
respStatus = Word8
20
, respMeta :: String
respMeta = String
"text/gemini"
, respBody :: Maybe ByteString
respBody = forall a. Maybe a
Nothing
}
newGemCapSettings
:: FilePath
-> FilePath
-> GemCapSettings
newGemCapSettings :: String -> String -> GemCapSettings
newGemCapSettings String
cert String
key = GemCapSettings
{ capConnections :: Int
capConnections = Int
100
, capPort :: Word16
capPort = Word16
1965
, capCert :: String
capCert = String
cert
, capCertChain :: [String]
capCertChain = []
, capKey :: String
capKey = String
key
}