wai-routes 0.7.0 → 0.7.1
raw patch · 5 files changed
+24/−18 lines, 5 filesdep ~aesonPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: aeson
API changes (from Hackage documentation)
- Network.Wai.Middleware.Routes: text :: Text -> HandlerM sub master ()
- Network.Wai.Middleware.Routes.Handler: text :: Text -> HandlerM sub master ()
+ Network.Wai.Middleware.Routes: plain :: Text -> HandlerM sub master ()
+ Network.Wai.Middleware.Routes: showRouteQuery :: RenderRoute master => Route master -> [(Text, Text)] -> Text
+ Network.Wai.Middleware.Routes.Handler: plain :: Text -> HandlerM sub master ()
+ Network.Wai.Middleware.Routes.Routes: showRouteQuery :: RenderRoute master => Route master -> [(Text, Text)] -> Text
- Network.Wai.Middleware.Routes: html :: ByteString -> HandlerM sub master ()
+ Network.Wai.Middleware.Routes: html :: Text -> HandlerM sub master ()
- Network.Wai.Middleware.Routes.Handler: html :: ByteString -> HandlerM sub master ()
+ Network.Wai.Middleware.Routes.Handler: html :: Text -> HandlerM sub master ()
Files
- README.md +2/−2
- src/Network/Wai/Middleware/Routes.hs +2/−1
- src/Network/Wai/Middleware/Routes/Handler.hs +5/−5
- src/Network/Wai/Middleware/Routes/Routes.hs +11/−6
- wai-routes.cabal +4/−4
README.md view
@@ -1,4 +1,4 @@-Wai Routes (wai-routes-0.7.0)+Wai Routes (wai-routes-0.7.1) ==================================== [](https://travis-ci.org/ajnsit/wai-routes)@@ -102,4 +102,4 @@ * 0.6.1 : Fixed cabal and travis files * 0.6.2 : Added 'maybeRoute' and 'routeAttrSet', to get information about the currently executing route * 0.7.0 : Subsites support added-+* 0.7.1 : Added 'showRouteQuery', renamed 'text' to 'plain', 'html' now accepts Text instead of ByteString
src/Network/Wai/Middleware/Routes.hs view
@@ -27,6 +27,7 @@ -- * URL rendering and parsing , showRoute+ , showRouteQuery , readRoute -- * Application Handlers@@ -65,7 +66,7 @@ , status -- | Set the response status , raw -- | Set the raw response body , json -- | Set the json response body- , text -- | Set the text response body+ , plain -- | Set the plain text response body , html -- | Set the html response body , next -- | Run the next application in the stack )
src/Network/Wai/Middleware/Routes/Handler.hs view
@@ -23,7 +23,7 @@ , status -- | Set the response status , raw -- | Set the raw response body , json -- | Set the json response body- , text -- | Set the text response body+ , plain -- | Set the plain text response body , html -- | Set the html response body , next -- | Run the next application in the stack )@@ -155,17 +155,17 @@ -- | Set the body of the response to the given 'Text' value. Also sets \"Content-Type\" -- header to \"text/plain\".-text :: Text -> HandlerM sub master ()-text t = do+plain :: Text -> HandlerM sub master ()+plain t = do header contentType typePlain raw $ encodeUtf8 t -- | Set the body of the response to the given 'Text' value. Also sets \"Content-Type\" -- header to \"text/html\".-html :: BL.ByteString -> HandlerM sub master ()+html :: Text -> HandlerM sub master () html s = do header contentType typeHtml- raw s+ raw $ encodeUtf8 s -- | Run the next application next :: HandlerM sub master ()
src/Network/Wai/Middleware/Routes/Routes.hs view
@@ -32,6 +32,7 @@ -- * URL rendering and parsing , showRoute+ , showRouteQuery , readRoute -- * Application Handlers@@ -192,14 +193,18 @@ -- Route information is filled in by runHandler routeDispatch master def req = dispatcher (_masterToEnv master) RequestData{waiReq=req, nextApp=def, currentRoute=Nothing} +-- | Render a `Route` and Query parameters to Text+showRouteQuery :: RenderRoute master => Route master -> [(Text,Text)] -> Text+showRouteQuery r q = uncurry _encodePathInfo $ second (map (second Just) . (++ q)) $ renderRoute r+ -- | Renders a `Route` as Text showRoute :: RenderRoute master => Route master -> Text-showRoute = uncurry encodePathInfo . second (map $ second Just) . renderRoute- where- encodePathInfo :: [Text] -> [(Text, Maybe Text)] -> Text- -- Slightly hackish: Convert "" into "/"- encodePathInfo [] = encodePathInfo [""]- encodePathInfo segments = decodeUtf8 . toByteString . encodePath segments . queryTextToQuery+showRoute = uncurry _encodePathInfo . second (map $ second Just) . renderRoute++_encodePathInfo :: [Text] -> [(Text, Maybe Text)] -> Text+-- Slightly hackish: Convert "" into "/"+_encodePathInfo [] = _encodePathInfo [""]+_encodePathInfo segments = decodeUtf8 . toByteString . encodePath segments . queryTextToQuery -- | Read a route from Text -- Returns Nothing if Route reading failed. Just route otherwise
wai-routes.cabal view
@@ -1,5 +1,5 @@ name : wai-routes-version : 0.7.0+version : 0.7.1 cabal-version : >=1.18 build-type : Simple license : MIT@@ -20,8 +20,8 @@ source-repository this type : git- location : http://github.com/ajnsit/wai-routes/tree/v0.7.0- tag : v0.7.0+ location : http://github.com/ajnsit/wai-routes/tree/v0.7.1+ tag : v0.7.1 library build-depends: base >= 4.7 && < 4.9@@ -29,7 +29,7 @@ , text >= 1.2 && < 1.3 , template-haskell >= 2.9 && < 2.11 , mtl >= 2.1 && < 2.3- , aeson >= 0.8 && < 0.9+ , aeson >= 0.8 && < 0.10 , containers >= 0.5 && < 0.6 , random >= 1.1 && < 1.2 , path-pieces >= 0.2 && < 0.3