WIP: partially implemented runGemServer

This commit is contained in:
Jonathan Lamothe 2021-10-28 20:50:20 -04:00
parent d021511bd6
commit 0aae14479d
3 changed files with 22 additions and 0 deletions

View File

@ -32,6 +32,7 @@ library
build-depends:
base >=4.7 && <5
, bytestring >=0.10.12.0 && <0.11
, network
, tcp-streams >=1.0.1.1 && <1.1
, text >=1.2.4.1 && <1.3
, tls
@ -53,6 +54,7 @@ test-suite gemserv-test
, bytestring >=0.10.12.0 && <0.11
, gemserv
, hspec >=2.7.10 && <2.8
, network
, tcp-streams >=1.0.1.1 && <1.1
, text >=1.2.4.1 && <1.3
, tls

View File

@ -27,6 +27,7 @@ dependencies:
- bytestring >= 0.10.12.0 && < 0.11
- tcp-streams >= 1.0.1.1 && < 1.1
- text >= 1.2.4.1 && < 1.3
- network
- tls
- x509

View File

@ -27,12 +27,14 @@ License along with this program. If not, see
{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards #-}
module Network.GemServ (
runGemServer,
encodeGemURL,
decodeGemURL,
escapeString,
unescapeString
) where
import Control.Exception.Base (bracket)
import qualified Data.ByteString as BS
import Data.ByteString.Builder (charUtf8, stringUtf8, toLazyByteString)
import qualified Data.ByteString.Lazy as BSL
@ -41,9 +43,26 @@ import Data.List (find, intercalate)
import Data.Maybe (fromJust)
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8')
import Network.Socket (close)
import System.IO.Streams.TCP (bindAndListen)
import Network.GemServ.Types
-- | Builds and runs a Gemini server
runGemServer
:: GemServSettings
-- ^ The server settings
-> GemHandler
-- ^ The handler
-> IO ()
runGemServer settings _ = bracket
( bindAndListen
(servConnections settings)
(fromIntegral $ servPort settings)
)
close
undefined
-- | Encodes a 'GemURL' into a 'String'
encodeGemURL :: GemURL -> String
encodeGemURL url =