我需要使用warp-tls而不是普通的warp服务器启动我的scotty应用程序,但似乎运行warp在scotty的源代码中是硬连线的。我错过了一些明显的东西吗?
答案 0 :(得分:2)
您可以使用scottyApp
函数代替scotty
来获取可以传递给warp Application
的WAI runTLS
:
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai.Handler.WarpTLS (runTLS, tlsSettings)
import Network.Wai.Handler.Warp (defaultSettings, setPort)
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
import Web.Scotty
main :: IO ()
main = do
let tlsConfig = tlsSettings "your.crt" "your.key"
config = setPort 3443 defaultSettings
waiApp <- scottyApp $ do
get "/" (text "hello")
get "/hello" (text "hello again")
runTLS tlsConfig config (logStdoutDev waiApp)