WIP: partially implemented runGemServer
This commit is contained in:
parent
d021511bd6
commit
0aae14479d
|
@ -32,6 +32,7 @@ library
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
, bytestring >=0.10.12.0 && <0.11
|
, bytestring >=0.10.12.0 && <0.11
|
||||||
|
, network
|
||||||
, tcp-streams >=1.0.1.1 && <1.1
|
, tcp-streams >=1.0.1.1 && <1.1
|
||||||
, text >=1.2.4.1 && <1.3
|
, text >=1.2.4.1 && <1.3
|
||||||
, tls
|
, tls
|
||||||
|
@ -53,6 +54,7 @@ test-suite gemserv-test
|
||||||
, bytestring >=0.10.12.0 && <0.11
|
, bytestring >=0.10.12.0 && <0.11
|
||||||
, gemserv
|
, gemserv
|
||||||
, hspec >=2.7.10 && <2.8
|
, hspec >=2.7.10 && <2.8
|
||||||
|
, network
|
||||||
, tcp-streams >=1.0.1.1 && <1.1
|
, tcp-streams >=1.0.1.1 && <1.1
|
||||||
, text >=1.2.4.1 && <1.3
|
, text >=1.2.4.1 && <1.3
|
||||||
, tls
|
, tls
|
||||||
|
|
|
@ -27,6 +27,7 @@ dependencies:
|
||||||
- bytestring >= 0.10.12.0 && < 0.11
|
- bytestring >= 0.10.12.0 && < 0.11
|
||||||
- tcp-streams >= 1.0.1.1 && < 1.1
|
- tcp-streams >= 1.0.1.1 && < 1.1
|
||||||
- text >= 1.2.4.1 && < 1.3
|
- text >= 1.2.4.1 && < 1.3
|
||||||
|
- network
|
||||||
- tls
|
- tls
|
||||||
- x509
|
- x509
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,14 @@ License along with this program. If not, see
|
||||||
{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards #-}
|
{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards #-}
|
||||||
|
|
||||||
module Network.GemServ (
|
module Network.GemServ (
|
||||||
|
runGemServer,
|
||||||
encodeGemURL,
|
encodeGemURL,
|
||||||
decodeGemURL,
|
decodeGemURL,
|
||||||
escapeString,
|
escapeString,
|
||||||
unescapeString
|
unescapeString
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Exception.Base (bracket)
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import Data.ByteString.Builder (charUtf8, stringUtf8, toLazyByteString)
|
import Data.ByteString.Builder (charUtf8, stringUtf8, toLazyByteString)
|
||||||
import qualified Data.ByteString.Lazy as BSL
|
import qualified Data.ByteString.Lazy as BSL
|
||||||
|
@ -41,9 +43,26 @@ import Data.List (find, intercalate)
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text.Encoding (decodeUtf8')
|
import Data.Text.Encoding (decodeUtf8')
|
||||||
|
import Network.Socket (close)
|
||||||
|
import System.IO.Streams.TCP (bindAndListen)
|
||||||
|
|
||||||
import Network.GemServ.Types
|
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'
|
-- | Encodes a 'GemURL' into a 'String'
|
||||||
encodeGemURL :: GemURL -> String
|
encodeGemURL :: GemURL -> String
|
||||||
encodeGemURL url =
|
encodeGemURL url =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user