-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | WAI middleware for authenticating webhook payloads from Travis CI
--   
--   This package provides a simple WAI middleware for authenticating
--   webhook payloads from <tt>travis-ci.com</tt>.
@package wai-middleware-travisci
@version 0.1.0


-- | <tt>travis-ci.com</tt> webhook authentication middleware.
--   
--   See
--   <a>https://docs.travis-ci.com/user/notifications/#Configuring-webhook-notifications</a>
--   for more information about webhooks.
--   
--   In brief:
--   
--   <ul>
--   <li>Configure <tt>travis-ci.com</tt> to send webhook notifications to
--   your <tt>WAI</tt>-based web server (such as
--   <tt><a>warp</a></tt>).</li>
--   <li>Use the <a>authenticate</a> middleware to reject requests that
--   don't originate from <tt>travis-ci.com</tt>.</li>
--   </ul>
--   
--   For example,
--   
--   <pre>
--   -- In .travis.yml
--   notifications:
--     webhooks: http://my-domain.com/my-webhook-path
--   </pre>
--   
--   <pre>
--   -- In code
--   TravisCI.<a>authenticate</a> ["my-webhook-path"]
--   </pre>
--   
--   See the bottom of this module for a longer example.
module Network.Wai.Middleware.TravisCI

-- | Only allow <tt>travis-ci.com</tt> to <tt>POST</tt> to the given path.
authenticate :: [Text] -> Middleware

-- | Retrieve the payload from an authenticated <a>Request</a>.
--   
--   This function <i>must</i> be called on a <a>Request</a> that was
--   handled by the <a>authenticate</a> middleware. Otherwise, it will
--   throw a <a>TravisNoValue</a> exception.
payload :: Request -> IO Value

data TravisException

-- | JSON-decoding an authenticated payload failed. This should never
--   happen; it means Travis CI signed and sent a payload that was not
--   valid JSON.
TravisNoParse :: Request -> TravisException

-- | A call to <a>payload</a> failed because there was no <a>Value</a>
--   inserted into the request vault by the <a>authenticate</a> middleware.
--   This should never happen, but if it does, it's your fault; it means
--   you called <a>payload</a> on a <a>Request</a> that did not pass
--   through the <a>authenticate</a> middleware.
TravisNoValue :: Request -> TravisException
instance GHC.Show.Show Network.Wai.Middleware.TravisCI.TravisException
instance GHC.Exception.Exception Network.Wai.Middleware.TravisCI.TravisException
