packages feed

servant-github-webhook 0.2.0.1 → 0.3.0.0

raw patch · 3 files changed

+18/−8 lines, 3 files

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for servant-github-webhook +## 0.3.0.0  -- 2016-09-22++* Pass reflected key index to the handler function for GitHubSignedReqBody.+  This allows for more generic handler functions, as they can determine+  programmatically which repository they are responding to.+ ## 0.2.0.1  -- 2016-09-13  * Improve documentation (formatting and typos) and examples (remove unnecessary
servant-github-webhook.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/  name:                servant-github-webhook-version:             0.2.0.1+version:             0.3.0.0 synopsis:            Servant combinators to facilitate writing GitHub webhooks. description:   This package provides servant combinators that make writing safe GitHub
src/Servant/GitHub/Webhook.hs view
@@ -198,7 +198,7 @@   type ServerT     (GitHubSignedReqBody'' ('KProxy :: KProxy k) key list result :> sublayout)     m-    = result -> ServerT sublayout m+    = (Demote key, result) -> ServerT sublayout m    route     :: forall env.@@ -207,7 +207,7 @@          :> sublayout        )     -> Context context-    -> Delayed env (result -> Server sublayout)+    -> Delayed env ((Demote key, result) -> Server sublayout)     -> Router env   route _ context subserver     = route (Proxy :: Proxy sublayout) context (addBodyCheck subserver go)@@ -217,7 +217,7 @@       keyIndex :: Demote key       keyIndex = reflect (Proxy :: Proxy key) -      go :: DelayedIO result+      go :: DelayedIO (Demote key, result)       go = withRequest $ \req -> do         let hdrs = requestHeaders req         key <- BS.unpack <$>@@ -238,7 +238,7 @@             Just h -> do               let h' = BS.drop 5 $ E.encodeUtf8 h -- remove "sha1=" prefix               if h' == sig-              then pure v+              then pure (keyIndex, v)               else delayedFailFatal err401  instance forall sublayout context events.@@ -400,6 +400,10 @@ -- > {-# LANGUAGE TypeFamilies #-} -- > {-# LANGUAGE TypeOperators #-} -- >+-- > module Main+-- > ( main+-- > ) where+-- > -- > import Control.Monad.IO.Class ( liftIO ) -- > import Data.Aeson ( Object ) -- > import qualified Data.ByteString as BS@@ -424,7 +428,7 @@ -- > server :: Server API -- > server = anyEvent -- >--- > anyEvent :: RepoWebhookEvent -> Object -> Handler ()+-- > anyEvent :: RepoWebhookEvent -> ((), Object) -> Handler () -- > anyEvent e _ -- >   = liftIO $ putStrLn $ "got event: " ++ show e -- >@@ -466,11 +470,11 @@ -- > server :: Server WebhookApi -- > server = repo1any :<|> repo2any -- >--- > repo1any :: RepoWebhookEvent -> Object -> Handler ()+-- > repo1any :: RepoWebhookEvent -> (Key, Object) -> Handler () -- > repo1any WebhookPingEvent _ = liftIO $ putStrLn "got ping on repo1!" -- > repo1any e _ = liftIO $ putStrLn $ "got event on repo 1: " ++ show e -- >--- > repo2any :: RepoWebhookEvent -> Object -> Handler ()+-- > repo2any :: RepoWebhookEvent -> (Key, Object) -> Handler () -- > repo2any e _ = liftIO $ putStrLn $ "got event on repo 2: " ++ show e -- > -- > api :: Proxy WebhookApi