From c280dccb627c9532d34f16afdaa2a4b6fcab1724 Mon Sep 17 00:00:00 2001 From: tusharad Date: Thu, 11 Apr 2024 11:49:30 +0530 Subject: [PATCH 1/3] Exposed simple cookie functions via Web.scotty & Trans --- Web/Scotty.hs | 2 ++ Web/Scotty/Trans.hs | 2 ++ changelog.md | 1 + 3 files changed, 5 insertions(+) diff --git a/Web/Scotty.hs b/Web/Scotty.hs index a58f5f8..0e919f5 100644 --- a/Web/Scotty.hs +++ b/Web/Scotty.hs @@ -52,6 +52,7 @@ module Web.Scotty -- * Types , ScottyM, ActionM, RoutePattern, File, Content(..), Kilobytes, ErrorHandler, Handler(..) , ScottyState, defaultScottyState + , module Web.Scotty.Cookie ) where import qualified Web.Scotty.Trans as Trans @@ -71,6 +72,7 @@ import qualified Network.Wai.Parse as W import Web.Scotty.Internal.Types (ScottyT, ActionT, ErrorHandler, Param, RoutePattern, Options, defaultOptions, File, Kilobytes, ScottyState, defaultScottyState, ScottyException, StatusError(..), Content(..)) import UnliftIO.Exception (Handler(..), catch) +import Web.Scotty.Cookie (setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie) {- $setup >>> :{ diff --git a/Web/Scotty/Trans.hs b/Web/Scotty/Trans.hs index 2320735..9ef98b4 100644 --- a/Web/Scotty/Trans.hs +++ b/Web/Scotty/Trans.hs @@ -60,6 +60,7 @@ module Web.Scotty.Trans -- * Monad Transformers , ScottyT, ActionT , ScottyState, defaultScottyState + , module Web.Scotty.Cookie ) where import Blaze.ByteString.Builder (fromByteString) @@ -84,6 +85,7 @@ import Web.Scotty.Util (socketDescription) import Web.Scotty.Body (newBodyInfo) import UnliftIO.Exception (Handler(..), catch) +import Web.Scotty.Cookie (setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie) -- | Run a scotty application using the warp server. diff --git a/changelog.md b/changelog.md index e944046..409c788 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ ## next [????.??.??] * Fixed cookie example from `Cookie` module documentation. `getCookie` Function would return strict variant of `Text`. Will convert it into lazy variant using `fromStrict`. +* Exposed simple functions of `Cookie` module via `Web.Scotty` & `Web.Scotty.Trans`. ### Breaking changes * Remove dependency on data-default class (#386). We have been exporting constants for default config values since 0.20, and this dependency was simply unnecessary. From 2f36660d3d2d6d3610cf5e0e898718631fa96cad Mon Sep 17 00:00:00 2001 From: tusharad Date: Thu, 11 Apr 2024 14:03:57 +0530 Subject: [PATCH 2/3] Added Explicit export list --- Web/Scotty.hs | 3 ++- Web/Scotty/Trans.hs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Web/Scotty.hs b/Web/Scotty.hs index 0e919f5..414eb3f 100644 --- a/Web/Scotty.hs +++ b/Web/Scotty.hs @@ -52,7 +52,8 @@ module Web.Scotty -- * Types , ScottyM, ActionM, RoutePattern, File, Content(..), Kilobytes, ErrorHandler, Handler(..) , ScottyState, defaultScottyState - , module Web.Scotty.Cookie + -- ** Functions from Cookie module + , setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie ) where import qualified Web.Scotty.Trans as Trans diff --git a/Web/Scotty/Trans.hs b/Web/Scotty/Trans.hs index 9ef98b4..8188c0b 100644 --- a/Web/Scotty/Trans.hs +++ b/Web/Scotty/Trans.hs @@ -60,7 +60,8 @@ module Web.Scotty.Trans -- * Monad Transformers , ScottyT, ActionT , ScottyState, defaultScottyState - , module Web.Scotty.Cookie + -- ** Functions from Cookie module + , setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie ) where import Blaze.ByteString.Builder (fromByteString) From 81da424af50d5f9587fb5db72b05ada9084ea6b4 Mon Sep 17 00:00:00 2001 From: tusharad Date: Thu, 18 Apr 2024 15:40:28 +0530 Subject: [PATCH 3/3] Changed cookies example as per new API --- examples/cookies.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/cookies.hs b/examples/cookies.hs index 7820c87..a6d19df 100644 --- a/examples/cookies.hs +++ b/examples/cookies.hs @@ -5,10 +5,10 @@ module Main (main) where import Control.Monad (forM_) import qualified Text.Blaze.Html5 as H -import Text.Blaze.Html5.Attributes -import Text.Blaze.Html.Renderer.Text (renderHtml) -import Web.Scotty -import Web.Scotty.Cookie (CookiesText, setSimpleCookie, getCookies) +import Text.Blaze.Html5.Attributes +import Text.Blaze.Html.Renderer.Text (renderHtml) +import Web.Scotty -- Web.Scotty exports setSimpleCookie,getCookies +import Web.Scotty.Cookie (CookiesText) renderCookiesTable :: CookiesText -> H.Html renderCookiesTable cs =