Popularity
4.0
Declining
Activity
0.0
Stable
6
3
1

Monthly Downloads: 17
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Web     Scotty    

scotty-cookie alternatives and similar packages

Based on the "scotty" category.
Alternatively, view scotty-cookie alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of scotty-cookie or a related project?

Add another 'scotty' Package

README

Usage example: simple hit counter

{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Data.Monoid
import Data.Maybe
import Data.Text.Read
import qualified Data.Text.Lazy as TL

import Web.Scotty
import Web.Scotty.Cookie

main :: IO ()
main = scotty 3000 $
    get "/" $ do
        hits <- liftM (fromMaybe "0") $ getCookie "hits"

        let hits' = case decimal hits of
                        Right n -> TL.pack . show . (+1) $ (fst n :: Integer)
                        Left _  -> "1"

        setSimpleCookie "hits" $ TL.toStrict hits'

        html $ mconcat [ "<html><body>"
                       , hits'
                       , "</body></html>"
                       ]