happstack-static-routing 0.2 → 0.3
raw patch · 2 files changed
+7/−6 lines, 2 files
Files
happstack-static-routing.cabal view
@@ -1,5 +1,5 @@ Name: happstack-static-routing-Version: 0.2+Version: 0.3 Synopsis: Support for static URL routing with overlap detection for Happstack. Description: If you have a large routing table in Happstack and want
src/Happstack/StaticRouting/Internal.hs view
@@ -35,15 +35,16 @@ type EndSegment = (Maybe Int, H.Method) -- | Support for varying number of arguments to 'path' handlers.-class Path m a b | a b -> m where- pathHandler :: (m b -> m c) -> a -> m c+class Path m hm a b | a b -> m hm where+ pathHandler :: (m b -> hm c) -> a -> hm c arity :: m b -> a -> Int -instance (FromReqURI d, ServerMonad m, MonadPlus m, Path m a b) => Path m (d -> a) b where+instance (FromReqURI d, ServerMonad hm, MonadPlus hm, Path m hm a b)+ => Path m hm (d -> a) b where pathHandler w f = H.path (pathHandler w . f) arity m f = 1 + arity m (f undefined) -instance Path m (m b) b where+instance Path m hm (m b) b where pathHandler w m = w m arity _ _ = 0 @@ -56,7 +57,7 @@ choice = Choice -- | Expect the given method, and exactly 'n' more segments, where 'n' is the arity of the handler.-path :: forall m h a b. Path m h a => H.Method -> (m a -> m b) -> h -> Route (m b)+path :: forall m hm h a b. Path m hm h a => H.Method -> (m a -> hm b) -> h -> Route (hm b) path m w h = Handler (Just (arity (undefined::m a) h),m) (pathHandler w h) -- | Expect zero or more segments.