module Network.Wai.Test.Internal where
import Network.Wai
import qualified Control.Monad.Trans.State as ST
import Control.Monad.Trans.Reader (ReaderT, runReaderT)
import Data.Map (Map)
import qualified Data.Map as Map
import qualified Web.Cookie as Cookie
import Data.ByteString (ByteString)
type Session = ReaderT Application (ST.StateT ClientState IO)
type ClientCookies = Map ByteString Cookie.SetCookie
data ClientState = ClientState
{ clientCookies :: ClientCookies
}
initState :: ClientState
initState = ClientState Map.empty
runSessionWith :: ClientState -> Session a -> Application -> IO (a, ClientState)
runSessionWith st session app = ST.runStateT (runReaderT session app) st