diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Marek Dolgos, mdmarek at gmail.com
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Network/Wai/Middleware/Router.hs b/Network/Wai/Middleware/Router.hs
new file mode 100644
--- /dev/null
+++ b/Network/Wai/Middleware/Router.hs
@@ -0,0 +1,52 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Network.Wai.Middleware.Router (Route,router,dir) where
+
+import Data.Text (Text,splitOn)
+import Network.Wai (Request(..),Application)
+
+-- | Alias for a function which maps path pieces to applications.
+type Route = ([Text] -> Maybe Application)
+
+
+-- | Router for mapping paths to applications.
+-- 
+-- For example:
+-- 
+-- > router [ dir "/foo" fooApp
+-- >        , dir "/api" apiApp 
+-- >        ] defaultApp
+router :: [Route] -> Application -> Application
+router routes d req = case router' (pathInfo req) routes of
+  Nothing -> d req
+  Just  a -> a req
+
+
+-- | First matching paths' application, nothing otherwise.
+router' :: [Text] -> [Route] -> Maybe Application
+router' _  []     = Nothing
+router' ps (r:rs) = case r ps of
+  Nothing -> router' ps rs
+  Just  a -> Just a
+  
+
+-- | A possible web application if the path matches, nothing otherwise.
+-- 
+-- For example:
+-- 
+-- > let f = dir "/foo/api" myApp
+-- > f ["foo","api"]
+-- > True
+-- > f ["foo","spi"]
+-- > False
+dir :: Text -> Application -> Route
+dir path a = let ps = pathPieces path
+             in  ( \xs -> if ps == xs 
+                          then Just  a
+                          else Nothing )
+
+
+-- | Pieces of a URL path.
+pathPieces :: Text -> [Text]
+pathPieces path = filter (""/=) $ splitOn "/" path
+                 
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/wai-router.cabal b/wai-router.cabal
new file mode 100644
--- /dev/null
+++ b/wai-router.cabal
@@ -0,0 +1,26 @@
+Name:                wai-router
+Version:             1.0.0.0
+Synopsis:            Provides basic routing on URL paths for WAI.
+Description:         Simple routing based on a URL path pieces mapped to web applications.
+License:             MIT
+License-file:        LICENSE
+Author:              Marek Dolgos
+Maintainer:          mdmarek@gmail.com
+Homepage:            http://github.com/mdmarek/wai-router
+Category:            Web
+Build-Type:          Simple
+Cabal-Version:       >=1.8
+Stability:           Stable
+
+Library
+  Build-Depends:     base >= 4   && < 5
+                   , wai  >= 1.0 && < 1.3
+                   , text >= 0.7 && < 0.12
+
+  Exposed-modules:   Network.Wai.Middleware.Router
+
+  ghc-options:       -Wall
+
+source-repository head
+  type:     git
+  location: git://github.com/mdmarek/wai-router.git
