Skip to content

Commit

Permalink
Exposed simple cookie functions via Main interface. (scotty-web#395)
Browse files Browse the repository at this point in the history
* Exposed simple cookie functions via Web.scotty & Trans

* Added Explicit export list

* Changed cookies example as per new API
  • Loading branch information
tusharad authored Apr 20, 2024
1 parent 8a55318 commit 85ed0b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Web/Scotty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ module Web.Scotty
-- * Types
, ScottyM, ActionM, RoutePattern, File, Content(..), Kilobytes, ErrorHandler, Handler(..)
, ScottyState, defaultScottyState
-- ** Functions from Cookie module
, setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie
) where

import qualified Web.Scotty.Trans as Trans
Expand All @@ -71,6 +73,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
>>> :{
Expand Down
3 changes: 3 additions & 0 deletions Web/Scotty/Trans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ module Web.Scotty.Trans
-- * Monad Transformers
, ScottyT, ActionT
, ScottyState, defaultScottyState
-- ** Functions from Cookie module
, setSimpleCookie,getCookie,getCookies,deleteCookie,makeSimpleCookie
) where

import Blaze.ByteString.Builder (fromByteString)
Expand All @@ -84,6 +86,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.
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 4 additions & 4 deletions examples/cookies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 85ed0b2

Please sign in to comment.