name:                wai-routing
version:             0.8
synopsis:            Declarative routing for WAI.
license:             OtherLicense
license-file:        LICENSE
author:              Toralf Wittner
maintainer:          Toralf Wittner <tw@dtex.org>
copyright:           (c) 2014 Toralf Wittner
homepage:            https://github.com/twittner/wai-routing/
bug-reports:         https://github.com/twittner/wai-routing/issues
stability:           experimental
category:            Web
build-type:          Simple
cabal-version:       >= 1.10

extra-source-files:
    README.md
    CHANGELOG.md
    examples/*.hs

description:
    Enables the declaration of \"routes\" which handle requests to a
    specific URL.
    .
    The set of possible handlers can be restricted by \"predicates\",
    which operate on WAI requests and have to be true or else the
    handler will not be called.
    .
    Example:
    .
    >import Data.ByteString (ByteString)
    >import Data.Text (Text)
    >import Network.Wai
    >import Network.Wai.Predicate
    >import Network.Wai.Routing
    >import Network.Wai.Handler.Warp
    >
    >main :: IO ()
    >main = run 8080 (route (prepare start))
    >
    >start :: Monad m => Routes a m ()
    >start = do
    >    get "/user/:name" fetchUser $
    >        capture "name"
    >
    >    get "/user/find" findUser $
    >        query "byName" ||| query "byId"
    >
    >    delete "/user/:name" rmUser $
    >        capture "name" .&. opt (cookie "foo")
    >
    >fetchUser :: Monad m => Text -> m Response
    >fetchUser name = ...
    >
    >findUser :: Monad m => Either ByteString Word64 -> m Response
    >findUser (Left  name)  = ...
    >findUser (Right ident) = ...
    >
    >rmUser :: Monad m => Text ::: Maybe Int -> m Response
    >rmUser (name ::: foo)  = ...

source-repository head
    type:             git
    location:         git://github.com/twittner/wai-routing.git

library
    default-language: Haskell2010
    hs-source-dirs:   src
    ghc-options:      -Wall -O2 -fwarn-tabs -funbox-strict-fields
    ghc-prof-options: -prof -auto-all

    exposed-modules:
        Network.Wai.Routing
        Network.Wai.Routing.Request
        Network.Wai.Routing.Route
        Network.Wai.Routing.Predicate

    build-depends:
        attoparsec       >= 0.10  && < 0.12
      , base             == 4.*
      , bytestring       >= 0.9   && < 0.11
      , bytestring-from  >= 0.2   && < 0.4
      , cookie           == 0.4.*
      , case-insensitive >= 1.1   && < 1.3
      , http-types       == 0.8.*
      , transformers     >= 0.3   && < 0.5
      , wai              >= 2.0   && < 2.2
      , wai-predicates   >= 0.6   && < 0.7
      , wai-route        == 0.1.*

test-suite wai-routing-tests
    type:             exitcode-stdio-1.0
    default-language: Haskell2010
    hs-source-dirs:   test
    main-is:          TestSuite.hs
    ghc-options:      -Wall -O2 -fwarn-tabs
    ghc-prof-options: -prof -auto-all

    other-modules:
        Tests.Wai.Route
        Tests.Wai.Util

    build-depends:
        base             == 4.*
      , blaze-builder    == 0.3.*
      , bytestring
      , case-insensitive
      , http-types
      , HUnit
      , QuickCheck
      , tasty            >= 0.8
      , tasty-hunit      >= 0.8
      , tasty-quickcheck >= 0.8
      , wai
      , wai-predicates
      , wai-routing

benchmark wai-routing-bench
    type:             exitcode-stdio-1.0
    default-language: Haskell2010
    main-is:          Bench.hs
    hs-source-dirs:   bench
    ghc-options:      -Wall -O2 -fwarn-tabs
    build-depends:
        base          == 4.*
      , criterion     == 0.8.*
      , http-types
      , wai
      , wai-predicates
      , wai-routing