name changes

changed names of certain functions and types to use the term "capsule" instead of "server"
This commit is contained in:
Jonathan Lamothe 2021-11-17 15:32:39 -05:00
parent f751ccf191
commit 722864c842
2 changed files with 30 additions and 30 deletions

View File

@ -32,7 +32,7 @@ License along with this program. If not, see
module Network.Gemini.Capsule ( module Network.Gemini.Capsule (
-- * Running a Gemini Server -- * Running a Gemini Server
runGemServer, runGemCapsule,
-- * Encoding/Decoding Functions -- * Encoding/Decoding Functions
encodeGemURL, encodeGemURL,
decodeGemURL, decodeGemURL,
@ -64,24 +64,24 @@ import System.IO.Streams.TLS (accept)
import Network.Gemini.Capsule.Internal import Network.Gemini.Capsule.Internal
import Network.Gemini.Capsule.Types import Network.Gemini.Capsule.Types
-- | Builds and runs a Gemini server -- | Builds and runs a Gemini capsule
runGemServer runGemCapsule
:: GemServSettings :: GemCapSettings
-- ^ The server settings -- ^ The capsule settings
-> GemHandler -> GemHandler
-- ^ The handler -- ^ The handler
-> IO a -> IO a
runGemServer settings handler = bracket runGemCapsule settings handler = bracket
( bindAndListen ( bindAndListen
(servConnections settings) (capConnections settings)
(fromIntegral $ servPort settings) (fromIntegral $ capPort settings)
) )
S.close S.close
( \sock -> do ( \sock -> do
params <- makeServerParams params <- makeServerParams
(servCert settings) (capCert settings)
(servCertChain settings) (capCertChain settings)
(servKey settings) (capKey settings)
listenLoop sock params handler listenLoop sock params handler
) )

View File

@ -30,12 +30,12 @@ module Network.Gemini.Capsule.Types (
GemRequest (..), GemRequest (..),
GemResponse (..), GemResponse (..),
GemHandler, GemHandler,
GemServSettings (..), GemCapSettings (..),
-- * Constructors -- * Constructors
newGemURL, newGemURL,
newGemRequest, newGemRequest,
newGemResponse, newGemResponse,
newGemServSettings newGemCapSettings
) where ) where
import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Lazy as BSL
@ -75,17 +75,17 @@ data GemResponse = GemResponse
-- | Handles a 'GemRequest' to produce a 'GemResponse' -- | Handles a 'GemRequest' to produce a 'GemResponse'
type GemHandler = GemRequest -> IO GemResponse type GemHandler = GemRequest -> IO GemResponse
-- | The settings required to set up a Gemini server -- | The settings required to set up a Gemini capsule
data GemServSettings = GemServSettings data GemCapSettings = GemCapSettings
{ servConnections :: Int { capConnections :: Int
-- ^ Number of simultaneous connections allowed -- ^ Number of simultaneous connections allowed
, servPort :: Word16 , capPort :: Word16
-- ^ The server port number -- ^ The capsule port number
, servCert :: FilePath , capCert :: FilePath
-- ^ The path to the server certificate -- ^ The path to the TLS certificate
, servCertChain :: [FilePath] , capCertChain :: [FilePath]
-- ^ The paths to the chain certificates -- ^ The paths to the chain certificates
, servKey :: FilePath , capKey :: FilePath
-- ^ The path to the private key -- ^ The path to the private key
} deriving (Eq, Show) } deriving (Eq, Show)
@ -120,18 +120,18 @@ newGemResponse = GemResponse
} }
-- | Builds a reasonable set of server settings. -- | Builds a reasonable set of server settings.
newGemServSettings newGemCapSettings
:: FilePath :: FilePath
-- ^ Path to the server certificate -- ^ Path to the server certificate
-> FilePath -> FilePath
-- ^ Path to the private key -- ^ Path to the private key
-> GemServSettings -> GemCapSettings
newGemServSettings cert key = GemServSettings newGemCapSettings cert key = GemCapSettings
{ servConnections = 100 { capConnections = 100
, servPort = 1965 , capPort = 1965
, servCert = cert , capCert = cert
, servCertChain = [] , capCertChain = []
, servKey = key , capKey = key
} }
--jl --jl