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

View File

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