wai-routes 0.2.2 → 0.2.3
raw patch · 3 files changed
+18/−11 lines, 3 filesdep +blaze-builderPVP ok
version bump matches the API change (PVP)
Dependencies added: blaze-builder
API changes (from Hackage documentation)
Files
- README +2/−1
- src/Network/Wai/Middleware/Routes/Routes.hs +12/−7
- wai-routes.cabal +4/−3
README view
@@ -1,4 +1,4 @@-Wai Routes (wai-routes-0.2.2)+Wai Routes (wai-routes-0.2.3) ============================== This package provides typesafe URLs for Wai applications.@@ -67,4 +67,5 @@ 0.2 : Updated functionality based on yesod-routes package 0.2.1 : Changed license to MIT 0.2.2 : Fixed license information in hs and cabal files+0.2.3 : Implemented a better showRoute function. Added blaze-builder as a dependency
src/Network/Wai/Middleware/Routes/Routes.hs view
@@ -41,20 +41,25 @@ -- Wai import Network.Wai (Middleware, Application, pathInfo, requestMethod)-import Network.HTTP.Types (StdMethod(GET), parseMethod)+import Network.HTTP.Types (StdMethod(GET), parseMethod, encodePath, queryTextToQuery) -- Yesod Routes import Yesod.Routes.Class (Route, RenderRoute(..)) import Yesod.Routes.Parse (parseRoutes, parseRoutesNoCheck, parseRoutesFile, parseRoutesFileNoCheck, parseType) import Yesod.Routes.TH (mkRenderRouteInstance, mkDispatchClause, ResourceTree(..)) --- Text+-- Text and Bytestring import qualified Data.Text as T import Data.Text (Text)+import Data.Text.Encoding (decodeUtf8)+import Blaze.ByteString.Builder (Builder, toByteString) -- TH import Language.Haskell.TH.Syntax +-- Convenience+import Control.Arrow (second)+ -- | Generates all the things needed for efficient routing, -- including your application's `Route` datatype, and a `RenderRoute` instance mkRoute :: String -> [ResourceTree String] -> Q [Dec]@@ -106,10 +111,10 @@ Left _ -> GET -- | Renders a `Route` as Text+-- Uses the `encodePath` function from http-types. Also performs utf8 encoding showRoute :: RenderRoute master => Route master -> Text--- TODO: Verify that intercalate "/" is sufficient and correct for all cases--- HACK: We add a '/' to the front of the URL (by adding an empty piece at--- the front of the url [Text]) to make everything relative to the root.--- This ensures that the links always work.-showRoute = T.intercalate (T.pack "/") . (T.pack "" :) . fst . renderRoute+showRoute = uncurry encodePathInfo . second (map $ second Just) . renderRoute+ where+ encodePathInfo :: [Text] -> [(Text, Maybe Text)] -> Text+ encodePathInfo segments = decodeUtf8 . toByteString . encodePath segments . queryTextToQuery
wai-routes.cabal view
@@ -1,5 +1,5 @@ Name: wai-routes-Version: 0.2.2+Version: 0.2.3 Synopsis: Typesafe URLs for Wai applications. Homepage: https://github.com/ajnsit/wai-routes License: MIT@@ -63,8 +63,8 @@ source-repository this type: git- location: http://github.com/ajnsit/wai-routes/tree/v0.2.2- tag: v0.2.2+ location: http://github.com/ajnsit/wai-routes/tree/v0.2.3+ tag: v0.2.3 Library hs-source-dirs: src@@ -73,6 +73,7 @@ , path-pieces , text , http-types >= 0.7+ , blaze-builder >= 0.2.1.4 && < 0.4 , template-haskell , yesod-routes >= 1.1 , mtl