yesod-core 1.4.18.1 → 1.4.18.2
raw patch · 5 files changed
+15/−3 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Yesod.Core: class RenderRoute site => Yesod site where approot = ApprootRelative errorHandler = defaultErrorHandler defaultLayout w = do { p <- widgetToPageContent w; mmsg <- getMessage; withUrlRenderer (\ _render_aQcv -> do { id ((preEscapedText . pack) "<!DOCTYPE html>\n\ \<html><head><title>"); id (toHtml (pageTitle p)); id ((preEscapedText . pack) "</title>"); asHtmlUrl (pageHead p) _render_aQcv; id ((preEscapedText . pack) "</head><body>"); maybeH mmsg (\ msg_aQcw -> do { id ((preEscapedText . pack) "<p class=\"message\">"); id (toHtml msg_aQcw); id ((preEscapedText . pack) "</p>") }) Nothing; asHtmlUrl (pageBody p) _render_aQcv; id ((preEscapedText . pack) "</body></html>") }) } urlRenderOverride _ _ = Nothing isAuthorized _ _ = return Authorized isWriteRequest _ = do { wai <- waiRequest; return $ requestMethod wai `notElem` ["GET", "HEAD", "OPTIONS", "TRACE"] } authRoute _ = Nothing cleanPath _ s = if corrected == s then Right $ map dropDash s else Left corrected where corrected = filter (not . null) s dropDash t | all (== '-') t = drop 1 t | otherwise = t joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs where pieces = if null pieces' then [""] else map addDash pieces' qs = map (encodeUtf8 *** go) qs' go "" = Nothing go x = Just $ encodeUtf8 x addDash t | all (== '-') t = cons '-' t | otherwise = t addStaticContent _ _ _ = return Nothing maximumContentLength _ _ = Just $ 2 * 1024 * 1024 makeLogger _ = defaultMakeLogger messageLoggerSource site = defaultMessageLoggerSource $ shouldLogIO site jsLoader _ = BottomOfBody makeSessionBackend _ = fmap Just $ defaultClientSessionBackend 120 defaultKeyFile fileUpload _ (KnownLength size) | size <= 50000 = FileUploadMemory lbsBackEnd fileUpload _ _ = FileUploadDisk tempFileBackEnd shouldLog _ = defaultShouldLog shouldLogIO a b c = return (shouldLog a b c) yesodMiddleware = defaultYesodMiddleware yesodWithInternalState _ _ = bracket createInternalState closeInternalState
+ Yesod.Core: class RenderRoute site => Yesod site where approot = ApprootRelative errorHandler = defaultErrorHandler defaultLayout w = do { p <- widgetToPageContent w; mmsg <- getMessage; withUrlRenderer (\ _render_aQen -> do { id ((preEscapedText . pack) "<!DOCTYPE html>\n\ \<html><head><title>"); id (toHtml (pageTitle p)); id ((preEscapedText . pack) "</title>"); asHtmlUrl (pageHead p) _render_aQen; id ((preEscapedText . pack) "</head><body>"); maybeH mmsg (\ msg_aQeo -> do { id ((preEscapedText . pack) "<p class=\"message\">"); id (toHtml msg_aQeo); id ((preEscapedText . pack) "</p>") }) Nothing; asHtmlUrl (pageBody p) _render_aQen; id ((preEscapedText . pack) "</body></html>") }) } urlRenderOverride _ _ = Nothing isAuthorized _ _ = return Authorized isWriteRequest _ = do { wai <- waiRequest; return $ requestMethod wai `notElem` ["GET", "HEAD", "OPTIONS", "TRACE"] } authRoute _ = Nothing cleanPath _ s = if corrected == s then Right $ map dropDash s else Left corrected where corrected = filter (not . null) s dropDash t | all (== '-') t = drop 1 t | otherwise = t joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs where pieces = if null pieces' then [""] else map addDash pieces' qs = map (encodeUtf8 *** go) qs' go "" = Nothing go x = Just $ encodeUtf8 x addDash t | all (== '-') t = cons '-' t | otherwise = t addStaticContent _ _ _ = return Nothing maximumContentLength _ _ = Just $ 2 * 1024 * 1024 makeLogger _ = defaultMakeLogger messageLoggerSource site = defaultMessageLoggerSource $ shouldLogIO site jsLoader _ = BottomOfBody makeSessionBackend _ = fmap Just $ defaultClientSessionBackend 120 defaultKeyFile fileUpload _ (KnownLength size) | size <= 50000 = FileUploadMemory lbsBackEnd fileUpload _ _ = FileUploadDisk tempFileBackEnd shouldLog _ = defaultShouldLog shouldLogIO a b c = return (shouldLog a b c) yesodMiddleware = defaultYesodMiddleware yesodWithInternalState _ _ = bracket createInternalState closeInternalState
- Yesod.Core.Handler: sendStatusJSON :: (MonadHandler m, ToJSON a) => Status -> a -> m a
+ Yesod.Core.Handler: sendStatusJSON :: (MonadHandler m, ToJSON c) => Status -> c -> m a
Files
- ChangeLog.md +4/−0
- Yesod/Core/Handler.hs +1/−1
- Yesod/Routes/TH/Dispatch.hs +2/−1
- test/YesodCoreTest/WaiSubsite.hs +7/−0
- yesod-core.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.4.18.2++* Allow subsites within hierarchical routes [#1144](https://github.com/yesodweb/yesod/pull/1144)+ ## 1.4.18 * Add hook to apply arbitrary function to all handlers [#1122](https://github.com/yesodweb/yesod/pull/1122)
Yesod/Core/Handler.hs view
@@ -580,7 +580,7 @@ -- | Bypass remaining handler code and output the given JSON with the given -- status code.-sendStatusJSON :: (MonadHandler m, ToJSON a) => H.Status -> a -> m a+sendStatusJSON :: (MonadHandler m, ToJSON c) => H.Status -> c -> m a sendStatusJSON s v = sendResponseStatus s (toJSON v) -- | Send a 201 "Created" response with the given route as the Location
Yesod/Routes/TH/Dispatch.hs view
@@ -176,11 +176,12 @@ subDispatcherE <- mdsSubDispatcher runHandlerE <- mdsRunHandler sub <- newName "sub"+ sroute <- newName "sroute" let sub2 = LamE [VarP sub] (foldl' (\a b -> a `AppE` b) (VarE (mkName getSub) `AppE` VarE sub) dyns) let reqExp' = setPathInfoE `AppE` VarE restPath `AppE` reqExp route' = foldl' AppE (ConE (mkName name)) dyns- route = foldr AppE route' extraCons+ route = LamE [VarP sroute] $ foldr AppE (AppE route' $ VarE sroute) extraCons exp = subDispatcherE `AppE` runHandlerE `AppE` sub2
test/YesodCoreTest/WaiSubsite.hs view
@@ -15,6 +15,8 @@ mkYesod "Y" [parseRoutes| / RootR GET /sub WaiSubsiteR WaiSubsite getApp+/nested NestedR:+ /sub NestedWaiSubsiteR WaiSubsite getApp |] instance Yesod Y@@ -34,5 +36,10 @@ it "subsite" $ app $ do res <- request defaultRequest { pathInfo = ["sub", "foo"] }+ assertStatus 200 res+ assertBodyContains "WAI" res++ it "nested subsite" $ app $ do+ res <- request defaultRequest { pathInfo = ["nested", "sub", "foo"] } assertStatus 200 res assertBodyContains "WAI" res
yesod-core.cabal view
@@ -1,5 +1,5 @@ name: yesod-core-version: 1.4.18.1+version: 1.4.18.2 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>