scotty-tls (empty) → 0.1.0.0
raw patch · 6 files changed
+121/−0 lines, 6 filesdep +basedep +scottydep +transformerssetup-changed
Dependencies added: base, scotty, transformers, wai, warp, warp-tls
Files
- LICENSE +30/−0
- README.md +17/−0
- Setup.hs +2/−0
- Web/Scotty/TLS.hs +32/−0
- examples/Main.hs +11/−0
- scotty-tls.cabal +29/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, David Johnson++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of David Johnson nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,17 @@+# Scotty-TLS++You can test by generating a self-signed certificate [here](http://www.akadia.com/services/ssh_test_certificate.html).++```haskell+{-# LANGUAGE OverloadedStrings #-}++import Data.Monoid (mconcat)+import Web.Scotty+import Web.Scotty.TLS++main :: IO ()+main = scottyTLS 3000 "server.key" "server.crt" $ do+ get "/:word" $ do+ beam <- param "word"+ html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Web/Scotty/TLS.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE RankNTypes #-}++module Web.Scotty.TLS+ ( -- * A method for running Scotty over TLS+ scottyTLS+ -- * Transformer version+ , scottyTTLS+ , module Web.Scotty.Trans+ ) where++import Control.Monad ((<=<))+import Control.Monad.IO.Class (MonadIO (liftIO))+import Network.Wai (Response)+import Network.Wai.Handler.Warp (Port, defaultSettings,+ settingsPort)+import Network.Wai.Handler.WarpTLS (certFile, defaultTlsSettings,+ keyFile, runTLS)+import Web.Scotty (scottyApp)+import Web.Scotty.Trans (ScottyM, ScottyT, scottyAppT)++-- | Run a Scotty application over TLS+scottyTLS :: Port -> FilePath -> FilePath -> ScottyM () -> IO ()+scottyTLS port key cert = runTLS+ (defaultTlsSettings { keyFile = key , certFile = cert })+ (defaultSettings { settingsPort = port }) <=< scottyApp++scottyTTLS :: (Monad m, MonadIO n) => Port -> FilePath -> FilePath ->+ (forall a. m a -> n a) -> (m Response -> IO Response) -> ScottyT m () -> n ()+scottyTTLS port key cert runM runToIO s = scottyAppT runM runToIO s >>= liftIO . runTLS+ (defaultTlsSettings { keyFile = key, certFile = cert })+ (defaultSettings { settingsPort = port })+
+ examples/Main.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE OverloadedStrings #-}++import Data.Monoid (mconcat)+import Web.Scotty+import Web.Scotty.TLS++main :: IO ()+main = scottyTLS 3000 "server.key" "server.crt" $ do+ get "/:word" $ do+ beam <- param "word"+ html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
+ scotty-tls.cabal view
@@ -0,0 +1,29 @@+name: scotty-tls+version: 0.1.0.0+synopsis: TLS for Scotty+description: Run your Scotty apps over TLS+homepage: https://github.com/dmjio/scotty-tls.git+license: BSD3+license-file: LICENSE+author: David Johnson+maintainer: djohnson.m@gmail.com+category: Web+build-type: Simple+cabal-version: >=1.10+Extra-source-files:+ README.md+ examples/Main.hs+library+ exposed-modules: Web.Scotty.TLS+ other-extensions: RankNTypes+ build-depends: base >=4.3.1 && < 5,+ scotty >=0.5.0,+ warp >= 1.3.4.1,+ warp-tls >=1.4.1.4,+ wai >= 1.3.0.1,+ transformers >= 0.3.0.0+ GHC-options: -Wall -fno-warn-orphans+ default-language: Haskell2010+source-repository head+ type: git+ location: git://github.com/dmjio/scotty-tls.git