wai-extra-3.1.17: Provides some basic WAI handlers and middleware.

Safe Haskell | None
Language | Haskell2010

Network.Wai.Test

Contents

- Session
- Client Cookies
- Requests
- Assertions

Synopsis

- type Session = ReaderT Application (StateT ClientState IO)
- runSession :: Session a -> Application -> IO a
- withSession :: Application -> Session a -> IO a
- type ClientCookies = Map ByteString SetCookie
- getClientCookies :: Session ClientCookies
- modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session ()
- setClientCookie :: SetCookie -> Session ()
- deleteClientCookie :: ByteString -> Session ()
- request :: Request -> Session SResponse
- srequest :: SRequest -> Session SResponse
- data SRequest = SRequest {
  - simpleRequest :: Request
  - simpleRequestBody :: ByteString
  }
- data SResponse = SResponse {
  - simpleStatus :: Status
  - simpleHeaders :: ResponseHeaders
  - simpleBody :: ByteString
  }
- defaultRequest :: Request
- setPath :: Request -> ByteString -> Request
- setRawPathInfo :: Request -> ByteString -> Request
- assertStatus :: HasCallStack => Int -> SResponse -> Session ()
- assertContentType :: HasCallStack => ByteString -> SResponse -> Session ()
- assertBody :: HasCallStack => ByteString -> SResponse -> Session ()
- assertBodyContains :: HasCallStack => ByteString -> SResponse -> Session ()
- assertHeader :: HasCallStack => CI ByteString -> ByteString -> SResponse -> Session ()
- assertNoHeader :: HasCallStack => CI ByteString -> SResponse -> Session ()
- assertClientCookieExists :: HasCallStack => String -> ByteString -> Session ()
- assertNoClientCookieExists :: HasCallStack => String -> ByteString -> Session ()
- assertClientCookieValue :: HasCallStack => String -> ByteString -> ByteString -> Session ()

# Session

type Session = ReaderT Application (StateT ClientState IO) #

runSession :: Session a -> Application -> IO a #

See also: `runSessionWith`.

withSession :: Application -> Session a -> IO a #

Synonym for 'flip runSession'

# Client Cookies

type ClientCookies = Map ByteString SetCookie #

Since 3.0.6

getClientCookies :: Session ClientCookies #

Since 3.0.6

modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session () #

Since 3.0.6

setClientCookie :: SetCookie -> Session () #

Since 3.0.6

deleteClientCookie :: ByteString -> Session () #

Since 3.0.6

# Requests

request :: Request -> Session SResponse #

srequest :: SRequest -> Session SResponse #

Similar to `request`, but allows setting the request body as a plain `ByteString`.

data SRequest #

Constructors

SRequest |

Fields

- simpleRequest :: Request
- simpleRequestBody :: ByteString

  Request body that will override the one set in `simpleRequest`.

  This is usually simpler than setting the body as a stateful IO-action in `simpleRequest`.

data SResponse #

Constructors

SResponse |

Fields

- simpleStatus :: Status
- simpleHeaders :: ResponseHeaders
- simpleBody :: ByteString

#### Instances

Instances details

Show SResponse # |
Instance details Defined in Network.Wai.Test Methods showsPrec :: Int -> SResponse -> ShowS # show :: SResponse -> String # showList :: [SResponse] -> ShowS #
Eq SResponse # |
Instance details Defined in Network.Wai.Test Methods (==) :: SResponse -> SResponse -> Bool # (/=) :: SResponse -> SResponse -> Bool #

defaultRequest :: Request #

A default, blank request.

Since: wai-2.0.0

setPath :: Request -> ByteString -> Request #

Set whole path (request path + query string).

setRawPathInfo :: Request -> ByteString -> Request #

# Assertions

assertStatus :: HasCallStack => Int -> SResponse -> Session () #

assertContentType :: HasCallStack => ByteString -> SResponse -> Session () #

assertBody :: HasCallStack => ByteString -> SResponse -> Session () #

assertBodyContains :: HasCallStack => ByteString -> SResponse -> Session () #

assertHeader :: HasCallStack => CI ByteString -> ByteString -> SResponse -> Session () #

assertNoHeader :: HasCallStack => CI ByteString -> SResponse -> Session () #

assertClientCookieExists :: HasCallStack => String -> ByteString -> Session () #

Since 3.0.6

assertNoClientCookieExists :: HasCallStack => String -> ByteString -> Session () #

Since 3.0.6

assertClientCookieValue :: HasCallStack => String -> ByteString -> ByteString -> Session () #

Since 3.0.6