Skip to content

Commit

Permalink
Fixed Cookie example from Cookie module (#391)
Browse files Browse the repository at this point in the history
* Fixed Cookie example from Cookie module

* modified changelog
  • Loading branch information
tusharad authored Apr 5, 2024
1 parent 8795345 commit ab5b6b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Web/Scotty/Cookie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import Data.Monoid
import Data.Maybe
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Read as TL (decimal)
import Web.Scotty (scotty, html)
import Web.Scotty (scotty, html, get)
import Web.Scotty.Cookie (getCookie, setSimpleCookie)
main :: IO ()
main = scotty 3000 $
get \"/\" $ do
hits <- liftM (fromMaybe \"0\") $ 'getCookie' \"hits\"
let hits' =
case TL.decimal hits of
case TL.decimal $ TL.fromStrict hits of
Right n -> TL.pack . show . (+1) $ (fst n :: Integer)
Left _ -> \"1\"
'setSimpleCookie' \"hits\" $ TL.toStrict hits'
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## next [????.??.??]

* Fixed cookie example from `Cookie` module documentation. `getCookie` Function would return strict variant of `Text`. Will convert it into lazy variant using `fromStrict`.

### 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

0 comments on commit ab5b6b5

Please sign in to comment.