packages feed

servant-github-webhook 0.3.0.1 → 0.3.0.2

raw patch · 5 files changed

+68/−26 lines, 5 filesdep +transformersdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

README.md view
@@ -1,3 +1,5 @@+[![Build Status](https://travis-ci.org/tsani/servant-github-webhook.svg?branch=master)](https://travis-ci.org/tsani/servant-github-webhook)+ servant-github-webhook ====================== 
servant-github-webhook.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/  name:                servant-github-webhook-version:             0.3.0.1+version:             0.3.0.2 synopsis:            Servant combinators to facilitate writing GitHub webhooks. description:   This package provides servant combinators that make writing safe GitHub@@ -19,7 +19,7 @@ copyright:           Jacob Thomas Errington 2016 category:            Web build-type:          Simple-tested-with:         GHC == 8.0.1+tested-with:         GHC == 7.10.2, GHC == 7.10.3, GHC == 8.0.1 extra-source-files:   ChangeLog.md   README.md@@ -29,6 +29,10 @@   type: git   location: https://github.com/tsani/servant-github-webhook.git +flag old-base+  description: whether to use base-4.8 and transformers rather than base 4.9+  default: True+ library   exposed-modules:     Servant.GitHub.Webhook@@ -38,18 +42,25 @@     -Wall   build-depends:     aeson >=0.11 && <1.1,-    base >=4.8 && <4.10,+    base16-bytestring >=0.1 && <0.2,     bytestring >= 0.10 && <0.11,+    Crypto >=4.2 && <4.3,+    github >=0.15 && <0.16,     http-types >=0.9 && <0.10,-    text >=1.2 && <1.3,     servant >=0.8 && <0.10,     servant-server >=0.8 && <0.10,-    github >=0.15 && <0.16,-    wai >=3.2 && <3.3,-    Crypto >=4.2 && <4.3,-    base16-bytestring >=0.1 && <0.2,-    string-conversions >=0.4 && <0.5+    string-conversions >=0.4 && <0.5,+    text >=1.2 && <1.3,+    wai >=3.2 && <3.3 +  if flag(old-base)+    build-depends:+      base >=4.8 && <4.9,+      transformers >=0.2 && <0.6+  else+    build-depends:+      base >=4.9 && <4.10+ test-suite multikey   type:                exitcode-stdio-1.0   ghc-options:@@ -66,6 +77,10 @@     wai,     warp +  if flag(old-base)+    build-depends:+      transformers >=0.2 && <0.6+ test-suite singlekey   type:                exitcode-stdio-1.0   ghc-options:@@ -81,3 +96,7 @@     servant-github-webhook,     wai,     warp++  if flag(old-base)+    build-depends:+      transformers >=0.2 && <0.6
src/Servant/GitHub/Webhook.hs view
@@ -38,6 +38,8 @@ retrieve. -} +{-# LANGUAGE CPP #-}+ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -51,6 +53,16 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +-- GHC 8 seems to have improved its decidability check for type family+-- instances and class instances. In particular, without UndecidableInstances+-- enabled, the Demote' instance for lists, which we need, will not compile.+-- Similarly, the Reflect instance for Symbol, which just requires KnownSymbol,+-- won't compile on GHC < 8 because the instance head is no smaller than the+-- instance head.+#if __GLASGOW_HASKELL__ < 800+{-# LANGUAGE UndecidableInstances #-}+#endif+ module Servant.GitHub.Webhook ( -- * Servant combinators   GitHubSignedReqBody''@@ -172,7 +184,7 @@ -- The type @key@ used here must correspond with @'Demote' k@ where @k@ is the -- kind whose types are used as indices in 'GitHubSignedReqBody''. ----- If you don't care about indices and just want to write a webhooks using a+-- If you don't care about indices and just want to write a webhook using a -- global key, see 'GitHubKey' which fixes @key@ to @()@ and use 'gitHubKey', -- which fills the newtype with a constant function. newtype GitHubKey' key = GitHubKey { unGitHubKey :: key -> IO BS.ByteString }
test/multikey/Main.hs view
@@ -15,8 +15,14 @@ import Servant import Servant.GitHub.Webhook +-- | Entry point for travis.+-- We don't actually have automated tests, so we use a dummy main for travis,+-- so that /running/ the tests passes, but compiling may not. main :: IO ()-main = do+main = pure ()++realMain :: IO ()+realMain = do   [k1, k2] <- C8.lines <$> BS.readFile "test/test-keys"   run 8080 (app (constKeys k1 k2)) @@ -26,13 +32,13 @@ server :: Server WebhookApi server = (repo1ping :<|> repo1any) :<|> repo2any -repo1ping :: RepoWebhookEvent -> Object -> Handler ()+repo1ping :: RepoWebhookEvent -> (Key, Object) -> Handler () repo1ping _ _ = liftIO $ putStrLn "got ping on repo1!" -repo1any :: RepoWebhookEvent -> Object -> Handler ()+repo1any :: RepoWebhookEvent -> (Key, Object) -> Handler () 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@@ -40,19 +46,19 @@  type WebhookApi   = "repo1" :> (-      GitHubEvent '[ 'WebhookPingEvent ]-    :> GitHubSignedReqBody' 'Repo1 '[JSON] Object-    :> Post '[JSON] ()-    :<|>-      GitHubEvent '[ 'WebhookWildcardEvent ]-    :> GitHubSignedReqBody' 'Repo1 '[JSON] Object-    :> Post '[JSON] ()+    GitHubEvent '[ 'WebhookPingEvent ]+      :> GitHubSignedReqBody' 'Repo1 '[JSON] Object+      :> Post '[JSON] ()+  :<|>+    GitHubEvent '[ 'WebhookWildcardEvent ]+      :> GitHubSignedReqBody' 'Repo1 '[JSON] Object+      :> Post '[JSON] ()   )   :<|>     "repo2"-    :> GitHubEvent '[ 'WebhookWildcardEvent ]-    :> GitHubSignedReqBody' 'Repo2 '[JSON] Object-    :> Post '[JSON] ()+      :> GitHubEvent '[ 'WebhookWildcardEvent ]+      :> GitHubSignedReqBody' 'Repo2 '[JSON] Object+      :> Post '[JSON] ()  type MyGitHubKey = GitHubKey' Key 
test/singlekey/Main.hs view
@@ -12,7 +12,10 @@ import Network.Wai.Handler.Warp ( run )  main :: IO ()-main = do+main = pure ()++realMain :: IO ()+realMain = do   [key, _] <- C8.lines <$> BS.readFile "test/test-keys"   run 8080 (app (gitHubKey $ pure key)) @@ -26,7 +29,7 @@ server :: Server API server = anyEvent -anyEvent :: RepoWebhookEvent -> Object -> Handler ()+anyEvent :: RepoWebhookEvent -> ((), Object) -> Handler () anyEvent e _   = liftIO $ putStrLn $ "got event: " ++ show e