1

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?

insitu
  • 4,488
  • 3
  • 25
  • 42

1 Answers1

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