Skip to content

Commit

Permalink
Fixed Cookie example from Cookie module
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharad committed Mar 27, 2024
1 parent 8795345 commit 23f286f
Showing 1 changed file with 2 additions and 2 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

0 comments on commit 23f286f

Please sign in to comment.