packages feed

web-inv-route 0.1.3.0 → 0.1.3.1

raw patch · 6 files changed

+30/−4 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Web.Route.Invertible: (!:?) :: RouteAction a b -> a -> BoundRoute
+ Web.Route.Invertible: infix 1 !:?
+ Web.Route.Invertible: requestBoundRoute :: BoundRoute -> Request
+ Web.Route.Invertible.Common: (:?) :: Route a -> a -> BoundRoute
+ Web.Route.Invertible.Common: data BoundRoute
+ Web.Route.Invertible.URI: boundRouteURI :: BoundRoute -> (Method, URI)
- Web.Route.Invertible.Render: renderHamletUrl :: (RouteAction a b, a) -> [(Text, Text)] -> Text
+ Web.Route.Invertible.Render: renderHamletUrl :: BoundRoute -> [(Text, Text)] -> Text

Files

Web/Route/Invertible.hs view
@@ -20,6 +20,8 @@   , routeRequest     -- * Reverse routing   , requestActionRoute+  , (!:?)+  , requestBoundRoute   ) where  import Control.Invertible.Monoidal
Web/Route/Invertible/Common.hs view
@@ -56,6 +56,7 @@   , routeAccepts   , routeCustom   , routePriority+  , BoundRoute(..)   , RouteAction(..)   , mapActionRoute     -- ** Supporting types
Web/Route/Invertible/Render.hs view
@@ -38,6 +38,6 @@   B.string8 (if requestSecure r then "https:" else "http:") <> renderRequestBuilder r q  -- |A 'Text.Hamlet.Render' function, suitable for passing to a @'Text.Hamlet.HtmlUrl' (RouteAction a b, a)@ template.-renderHamletUrl :: (RouteAction a b, a) -> [(T.Text, T.Text)] -> T.Text-renderHamletUrl (r, a) q = TE.decodeUtf8 $ BSL.toStrict $ B.toLazyByteString-  $ renderRequestBuilder (requestActionRoute r a) $ queryTextToQuery $ map (second Just) q+renderHamletUrl :: BoundRoute -> [(T.Text, T.Text)] -> T.Text+renderHamletUrl (r :? a) q = TE.decodeUtf8 $ BSL.toStrict $ B.toLazyByteString+  $ renderRequestBuilder (requestRoute r a) $ queryTextToQuery $ map (second Just) q
Web/Route/Invertible/Route.hs view
@@ -19,9 +19,12 @@   , foldRoute   , requestRoute'   , requestRoute+  , BoundRoute(..)+  , requestBoundRoute   , RouteAction(..)   , mapActionRoute   , requestActionRoute+  , (!:?)   ) where  import Control.Invertible.Monoidal@@ -185,6 +188,15 @@ requestRoute :: Route a -> a -> Request requestRoute r a = requestRoute' r a blankRequest +-- |A route bound with its parameter.  Useful for passing concerete specific routes without type variables.+data BoundRoute = forall a. Route a :? a++infix 1 :?++-- |Apply 'requestRoute' on a 'BoundRoute'.+requestBoundRoute :: BoundRoute -> Request+requestBoundRoute (r :? a) = requestRoute r a+ -- |Specify the action to take for a given route, often used as an infix operator between the route specification and the function used to produce the result (which usually generates the HTTP response, but could be anything). data RouteAction a b = RouteAction   { actionRoute :: !(Route a)@@ -204,3 +216,9 @@ -- |Apply 'requestRoute' to 'actionRoute'. requestActionRoute :: RouteAction a b -> a -> Request requestActionRoute = requestRoute . actionRoute++-- |Combine '(:?)' and 'actionRoute'.+(!:?) :: RouteAction a b -> a -> BoundRoute+(!:?) = (:?) . actionRoute++infix 1 !:?
Web/Route/Invertible/URI.hs view
@@ -13,6 +13,7 @@   , uriRequest   , uriGETRequest   , routeActionURI+  , boundRouteURI   ) where  import Control.Arrow ((&&&))@@ -58,3 +59,7 @@ -- |Reverse a route action to a URI. routeActionURI :: RouteAction r a -> r -> (Method, URI) routeActionURI r = (requestMethod &&& requestURI) . requestActionRoute r++-- |Reverse a bound route action to a URI.+boundRouteURI :: BoundRoute -> (Method, URI)+boundRouteURI = (requestMethod &&& requestURI) . requestBoundRoute
web-inv-route.cabal view
@@ -1,5 +1,5 @@ name:                web-inv-route-version:             0.1.3.0+version:             0.1.3.1 synopsis:            Composable, reversible, efficient web routing using invertible invariants and bijections description:   Utilities to route HTTP requests, mainly focused on path components.  Routes are specified using bijections and invariant functors, allowing run-time composition (routes can be distributed across modules), reverse and forward routing derived from the same specification, and O(log n) lookups.