packages feed

github-webhook-handler-snap (empty) → 0.0.1

raw patch · 4 files changed

+84/−0 lines, 4 filesdep +basedep +bytestringdep +case-insensitivesetup-changed

Dependencies added: base, bytestring, case-insensitive, github-types, github-webhook-handler, snap-core

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Tomas Carnecky++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ github-webhook-handler-snap.cabal view
@@ -0,0 +1,34 @@+name:                github-webhook-handler-snap+version:             0.0.1++synopsis:            GitHub WebHook Handler implementation for Snap+description:+  ...++license:             MIT+license-file:        LICENSE++author:              Tomas Carnecky+maintainer:          tomas.carnecky@gmail.com++category:            GitHub++build-type:          Simple+cabal-version:       >=1.10+++library+  hs-source-dirs:      src+  default-language:    Haskell2010+  ghc-options:         -Wall++  build-depends:+     base >=4.8 && <4.9+   , bytestring+   , case-insensitive+   , snap-core+   , github-types+   , github-webhook-handler++  exposed-modules:+     GitHub.WebHook.Handler.Snap
+ src/GitHub/WebHook/Handler/Snap.hs view
@@ -0,0 +1,28 @@+module GitHub.WebHook.Handler.Snap+  ( webhookHandler+  ) where+++import           Data.ByteString+import qualified Data.ByteString.Lazy as LBS+import qualified Data.CaseInsensitive as CI++import           Snap.Core++import           GitHub.Types+import           GitHub.WebHook.Handler++++webhookHandler :: ByteString -> Maybe String -> (Either Error Event -> Snap ()) -> Snap ()+webhookHandler hookPath mbSecretKey m =+    path hookPath $ method POST $ runHandler handler+  where+    handler = Handler+        { hSecretKey = mbSecretKey+        , hBody = fmap LBS.toStrict $ readRequestBody (100 * 1000)+        , hHeader = \name -> do+            hdrs <- headers <$> getRequest+            return $ getHeader (CI.mk name) hdrs+        , hAction = \res -> m res >> getResponse >>= finishWith+        }