implemented GemResponse type and constructor

This commit is contained in:
Jonathan Lamothe 2021-10-28 19:31:28 -04:00
parent d1f26115f6
commit 7addd8982f

View File

@ -28,12 +28,15 @@ module Network.GemServ.Types (
-- * Types -- * Types
GemURL (..), GemURL (..),
GemRequest (..), GemRequest (..),
GemResponse (..),
-- * Constructors -- * Constructors
newGemURL, newGemURL,
newGemRequest newGemRequest,
newGemResponse,
) where ) where
import Data.Word (Word32) import qualified Data.ByteString as BS
import Data.Word (Word8, Word32)
import Data.X509 (Certificate) import Data.X509 (Certificate)
-- | Gemini URL -- | Gemini URL
@ -56,6 +59,16 @@ data GemRequest = GemRequest
-- ^ The client certificate (if available) -- ^ The client certificate (if available)
} deriving (Eq, Show) } deriving (Eq, Show)
-- | Describes a response to a Gemini request
data GemResponse = GemResponse
{ respStatus :: Word8
-- ^ The response status code
, respMeta :: String
-- ^ The response metadata
, respBody :: Maybe BS.ByteString
-- ^ The response body
} deriving (Eq, Show)
-- | Builds a new 'GemURL' -- | Builds a new 'GemURL'
newGemURL newGemURL
:: String :: String
@ -78,4 +91,12 @@ newGemRequest url = GemRequest
, reqCert = Nothing , reqCert = Nothing
} }
-- | Builds a 'GemResponse'
newGemResponse :: GemResponse
newGemResponse = GemResponse
{ respStatus = 20
, respMeta = "text/gemini"
, respBody = Nothing
}
--jl --jl