implemented GemServSettings type and constructor
This commit is contained in:
parent
8c50721309
commit
f943b50a20
|
@ -30,15 +30,17 @@ module Network.GemServ.Types (
|
|||
GemRequest (..),
|
||||
GemResponse (..),
|
||||
GemHandler,
|
||||
GemServSettings (..),
|
||||
-- * Constructors
|
||||
newGemURL,
|
||||
newGemRequest,
|
||||
newGemResponse,
|
||||
newGemServSettings
|
||||
) where
|
||||
|
||||
import Control.Monad.Trans.Reader (ReaderT)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.Word (Word8, Word32)
|
||||
import Data.Word (Word8, Word16, Word32)
|
||||
import Data.X509 (Certificate)
|
||||
|
||||
-- | Gemini URL
|
||||
|
@ -74,6 +76,20 @@ data GemResponse = GemResponse
|
|||
-- | Handles a 'GemRequest' to produce a 'GemResponse'
|
||||
type GemHandler m = ReaderT GemRequest m GemResponse
|
||||
|
||||
-- | The settings required to set up a Gemini server
|
||||
data GemServSettings = GemServSettings
|
||||
{ servConnections :: Int
|
||||
-- ^ Number of simultaneous connections allowed
|
||||
, servPort :: Word16
|
||||
-- ^ The server port number
|
||||
, servCert :: FilePath
|
||||
-- ^ The path to the server certificate
|
||||
, servCertChain :: [FilePath]
|
||||
-- ^ The paths to the chain certificates
|
||||
, servKey :: FilePath
|
||||
-- ^ The path to the private key
|
||||
} deriving (Eq, Show)
|
||||
|
||||
-- | Builds a new 'GemURL'
|
||||
newGemURL
|
||||
:: String
|
||||
|
@ -104,4 +120,21 @@ newGemResponse = GemResponse
|
|||
, respBody = Nothing
|
||||
}
|
||||
|
||||
-- | Builds a reasonable set of server settings.
|
||||
newGemServSettings
|
||||
:: FilePath
|
||||
-- ^ Path to the server certificate
|
||||
-> [FilePath]
|
||||
-- ^ Path to the chain certificates
|
||||
-> FilePath
|
||||
-- ^ Path to the private key
|
||||
-> GemServSettings
|
||||
newGemServSettings cert chain key = GemServSettings
|
||||
{ servConnections = 100
|
||||
, servPort = 1965
|
||||
, servCert = cert
|
||||
, servCertChain = chain
|
||||
, servKey = key
|
||||
}
|
||||
|
||||
--jl
|
||||
|
|
Loading…
Reference in New Issue
Block a user