scotty-tls 0.4.1 → 0.5.0
raw patch · 3 files changed
+35/−17 lines, 3 filesdep ~basedep ~scottydep ~waiPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, scotty, wai, warp, warp-tls
API changes (from Hackage documentation)
+ Web.Scotty.TLS: data ScottyT (m :: Type -> Type) a
+ Web.Scotty.TLS: scottyAppT :: (Monad m, Monad n) => Options -> (m Response -> IO Response) -> ScottyT m () -> n Application
- Web.Scotty.TLS: scottyTTLS :: (Monad m, MonadIO n) => Port -> FilePath -> FilePath -> (m Response -> IO Response) -> ScottyT t m () -> n ()
+ Web.Scotty.TLS: scottyTTLS :: (Monad m, MonadIO n) => Port -> FilePath -> FilePath -> (m Response -> IO Response) -> ScottyT m () -> n ()
Files
- README.md +11/−1
- Web/Scotty/TLS.hs +18/−10
- scotty-tls.cabal +6/−6
README.md view
@@ -1,6 +1,16 @@ # Scotty-TLS -You can test by generating a self-signed certificate [here](http://www.akadia.com/services/ssh_test_certificate.html).+You can test by generating a self-signed certificate like this:++```sh+openssl req -nodes -newkey rsa:2048 -keyout example.key -out example.csr \+ -subj "/C=GB/ST=London/L=London/O=Acme Widgets/OU=IT Department/CN=example.com"+openssl x509 -req -days 365 -in example.csr -signkey example.key -out example.crt+```+For more details on making certificates, see [this guide](http://www.akadia.com/services/ssh_test_certificate.html).+++Install and run with: ```text cabal update && cabal install scotty-tls
Web/Scotty/TLS.hs view
@@ -14,15 +14,15 @@ import Network.Wai (Response) import Network.Wai.Handler.Warp (Port, defaultSettings, setPort)-import Network.Wai.Handler.WarpTLS (certFile, defaultTlsSettings,- keyFile, runTLS, TLSSettings(..))-import Web.Scotty (scottyApp, ScottyM)+import Network.Wai.Handler.WarpTLS (tlsSettings,+ runTLS, TLSSettings(..))+import Web.Scotty (scottyApp, ScottyM, defaultOptions) import Web.Scotty.Trans (ScottyT, scottyAppT) -- | Run a Scotty application over TLS scottyTLS :: Port -> FilePath -> FilePath -> ScottyM () -> IO () scottyTLS port key cert = runTLS- (defaultTlsSettings { keyFile = key , certFile = cert })+ (tlsSettings cert key) (setPort port defaultSettings) <=< scottyApp scottyTLSSettings :: Port -> TLSSettings -> ScottyM () -> IO ()@@ -30,9 +30,17 @@ settings (setPort port defaultSettings) <=< scottyApp -scottyTTLS :: (Monad m, MonadIO n) => Port -> FilePath -> FilePath ->- (m Response -> IO Response) -> ScottyT t m () -> n ()-scottyTTLS port key cert runToIO s = scottyAppT runToIO s >>= liftIO . runTLS- (defaultTlsSettings { keyFile = key, certFile = cert })- (setPort port defaultSettings)-+scottyTTLS+ :: (Monad m, MonadIO n)+ => Port+ -> FilePath+ -> FilePath+ -> (m Response -> IO Response)+ -> ScottyT m ()+ -> n ()+scottyTTLS port key cert runToIO s = do+ app <- scottyAppT defaultOptions runToIO s+ liftIO $ runTLS+ (tlsSettings cert key)+ (setPort port defaultSettings)+ app
scotty-tls.cabal view
@@ -1,5 +1,5 @@ name: scotty-tls-version: 0.4.1+version: 0.5.0 synopsis: TLS for Scotty description: Run your Scotty apps over TLS homepage: https://github.com/dmjio/scotty-tls.git@@ -17,11 +17,11 @@ library exposed-modules: Web.Scotty.TLS other-extensions: RankNTypes- build-depends: base >=4.3.1 && < 5,- scotty >=0.10.0,- warp >= 1.3.4.1,- warp-tls >=1.4.1.4,- wai >= 1.3.0.1,+ build-depends: base < 5,+ scotty >=0.21.0,+ warp >= 3.3,+ warp-tls >= 3.4,+ wai >= 3.2, transformers >= 0.3.0.0 GHC-options: -Wall -fno-warn-orphans default-language: Haskell2010