Hoogle Search
Within LTS Haskell 24.52 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
singletons-base Prelude.Singletons No documentation available.
-
singletons-base Prelude.Singletons No documentation available.
-
singletons-base Prelude.Singletons No documentation available.
-
snap-core Snap.Core Contains all of the information about an incoming HTTP request.
getRequest :: MonadSnap m => m Requestsnap-core Snap.Core Grabs the Request object out of the Snap monad. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> let r = T.get "/foo/bar" M.empty ghci> T.runHandler r (writeBS . rqURI =<< getRequest) HTTP/1.1 200 OK server: Snap/test date: Sat, 02 Aug 2014 07:51:54 GMT /foo/bar
getsRequest :: MonadSnap m => (Request -> a) -> m asnap-core Snap.Core Grabs something out of the Request object, using the given projection function. See gets. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> let r = T.get "/foo/bar" M.empty ghci> T.runHandler r (writeBS =<< getsRequest rqURI) HTTP/1.1 200 OK server: Snap/test date: Sat, 02 Aug 2014 07:51:54 GMT /foo/bar
localRequest :: MonadSnap m => (Request -> Request) -> m a -> m asnap-core Snap.Core Runs a Snap action with a locally-modified Request state object. The Request object in the Snap monad state after the call to localRequest will be unchanged. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> let r = T.get "/foo/bar" M.empty ghci> r' <- T.buildRequest $ T.get "/bar/foo" M.empty ghci> let printRqURI = getsRequest rqURI >>= writeBS >> writeBS "\n" ghci> T.runHandler r (printRqURI >> localRequest (const r') printRqURI) HTTP/1.1 200 OK server: Snap/test date: Wed, 06 Aug 2014 15:34:12 GMT /foo/bar /bar/foo
modifyRequest :: MonadSnap m => (Request -> Request) -> m ()snap-core Snap.Core Modifies the Request object stored in a Snap monad. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> let r = T.get "/foo/bar" M.empty ghci> r' <- T.buildRequest $ T.get "/bar/foo" M.empty ghci> T.runHandler r (modifyRequest (const r') >> getsRequest rqURI >>= writeBS) HTTP/1.1 200 OK server: Snap/test date: Wed, 06 Aug 2014 15:24:25 GMT /bar/foo
putRequest :: MonadSnap m => Request -> m ()snap-core Snap.Core Puts a new Request object into the Snap monad. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> :{ ghci| let hndlr = do rq <- T.buildRequest (T.get "/bar/foo" M.empty) ghci| putRequest rq ghci| uri' <- getsRequest rqURI ghci| writeBS uri' ghci| :} ghci> T.runHandler (T.get "/foo/bar" M.empty) hndlr HTTP/1.1 200 OK server: Snap/test date: Wed, 06 Aug 2014 15:13:46 GMT /bar/foo
readRequestBody :: MonadSnap m => Word64 -> m ByteStringsnap-core Snap.Core Returns the request body as a lazy bytestring. /Note that the request is not actually provided lazily!/ Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> import qualified Snap.Test as T ghci> let r = T.put "/foo" "text/plain" "some text" ghci> T.runHandler r (readRequestBody 2048 >>= writeLBS) HTTP/1.1 200 OK server: Snap/test date: Thu, 07 Aug 2014 20:08:44 GMT some text
Since: 0.6