I need to start my scotty application with warp-tls instead of plain warp server but is seems running warp is hardwired in scotty's source code. Am I missing something obvious?
Asked
Active
Viewed 700 times
1
-
1You can use the function `scottyApp` instead of `scotty` to get a WAI `Application`. From there it's Scotty independent and you can pass it to warp's `runTLS` function. – Shaun the Sheep Dec 01 '15 at 22:15
-
`\p s -> run p =<< scottyApp s` = `scotty` :) – Athan Clark Dec 02 '15 at 01:30
-
/me stupid If you lift your comment into an answer I will accept it :-) – insitu Dec 02 '15 at 08:47
1 Answers
2
You can use the scottyApp
function instead of scotty
, to get a WAI Application
which you can pass to warp's 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)

Shaun the Sheep
- 22,353
- 1
- 72
- 100