github-webhook-handler 0.0.5 → 0.0.6
raw patch · 2 files changed
+7/−11 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- GitHub.WebHook.Handler: [hAction] :: Handler m -> Either Error (UUID, Payload) -> m ()
- GitHub.WebHook.Handler: Handler :: [String] -> m ByteString -> (ByteString -> m (Maybe ByteString)) -> (Either Error (UUID, Payload) -> m ()) -> Handler m
+ GitHub.WebHook.Handler: Handler :: [String] -> m ByteString -> (ByteString -> m (Maybe ByteString)) -> Handler m
- GitHub.WebHook.Handler: runHandler :: Monad m => Handler m -> m ()
+ GitHub.WebHook.Handler: runHandler :: Monad m => Handler m -> m (Either Error (UUID, Payload))
Files
github-webhook-handler.cabal view
@@ -1,5 +1,5 @@ name: github-webhook-handler-version: 0.0.5+version: 0.0.6 synopsis: GitHub WebHook Handler description:
src/GitHub/WebHook/Handler.hs view
@@ -41,10 +41,6 @@ , hHeader :: ByteString -> m (Maybe ByteString) -- ^ Action which is used to retrieve a particular header from the -- request.-- , hAction :: Either Error (UUID, Payload) -> m ()- -- ^ Action which is executed once we've processed all the information- -- in the request. GitHub includes a unique UUID in each request. } @@ -78,15 +74,15 @@ (hmacGetDigest (hmac (BC8.pack key) rawBody :: HMAC SHA1))) -runHandler :: Monad m => Handler m -> m ()+runHandler :: Monad m => Handler m -> m (Either Error (UUID, Payload)) runHandler h = do- mbDelivery <- return . (fromASCIIBytes =<<) =<< hHeader h "X-GitHub-Delivery"+ mbDelivery <- pure . (fromASCIIBytes =<<) =<< hHeader h "X-GitHub-Delivery" res <- do rawBody <- hBody h mbSignature <- hHeader h "X-Hub-Signature" - authenticatedBody <- return $ case (hSecretKeys h, mbSignature) of+ authenticatedBody <- pure $ case (hSecretKeys h, mbSignature) of -- No secret key and no signature. Pass along the body unverified. ([], Nothing) -> Right rawBody@@ -108,7 +104,7 @@ else Left InvalidSignature mbEventName <- hHeader h "X-GitHub-Event"- return $ do+ pure $ do eventName <- maybe (Left InvalidRequest) Right mbEventName body <- authenticatedBody case eitherDecodeStrict' body of@@ -116,6 +112,6 @@ Right value -> either toParseError Right $ parseEither (webhookPayloadParser $ decodeUtf8 eventName) value - hAction h $ case mbDelivery of- Nothing -> Left InvalidRequest+ pure $ case mbDelivery of+ Nothing -> Left InvalidRequest Just uuid -> fmap ((,) uuid) res