Network.Wai.Parse

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

Safe Haskell | None
Language | Haskell98

Network.Wai.Parse

Description

Some helpers for parsing data out of a raw WAI `Request`.

Synopsis

- parseHttpAccept :: ByteString -> [ByteString]
- parseRequestBody :: BackEnd y -> Request -> IO ([Param], [File y])
- data RequestBodyType
  - = UrlEncoded
  - | Multipart ByteString
- getRequestBodyType :: Request -> Maybe RequestBodyType
- sinkRequestBody :: BackEnd y -> RequestBodyType -> IO ByteString -> IO ([Param], [File y])
- type BackEnd a = ByteString -> FileInfo () -> IO ByteString -> IO a
- lbsBackEnd :: Monad m => ignored1 -> ignored2 -> m ByteString -> m ByteString
- tempFileBackEnd :: InternalState -> ignored1 -> ignored2 -> IO ByteString -> IO FilePath
- tempFileBackEndOpts :: IO FilePath -> String -> InternalState -> ignored1 -> ignored2 -> IO ByteString -> IO FilePath
- type Param = (ByteString, ByteString)
- type File y = (ByteString, FileInfo y)
- data FileInfo c = FileInfo {
  - fileName :: ByteString
  - fileContentType :: ByteString
  - fileContent :: c
  }
- parseContentType :: ByteString -> (ByteString, [(ByteString, ByteString)])

# Documentation

parseHttpAccept :: ByteString -> [ByteString]

Parse the HTTP accept string to determine supported content types.

parseRequestBody :: BackEnd y -> Request -> IO ([Param], [File y])

data RequestBodyType

Constructors

UrlEncoded |
Multipart ByteString |

getRequestBodyType :: Request -> Maybe RequestBodyType

sinkRequestBody :: BackEnd y -> RequestBodyType -> IO ByteString -> IO ([Param], [File y])

type BackEnd a

Arguments

= ByteString | parameter name
-> FileInfo () |
-> IO ByteString |
-> IO a |

A file uploading backend. Takes the parameter name, file name, and a stream of data.

lbsBackEnd :: Monad m => ignored1 -> ignored2 -> m ByteString -> m ByteString

Store uploaded files in memory

tempFileBackEnd :: InternalState -> ignored1 -> ignored2 -> IO ByteString -> IO FilePath

Save uploaded files on disk as temporary files

Note: starting with version 2.0, removal of temp files is registered with the provided `InternalState`. It is the responsibility of the caller to ensure that this `InternalState` gets cleaned up.

tempFileBackEndOpts

Arguments

:: IO FilePath | get temporary directory
-> String | filename pattern
-> InternalState |
-> ignored1 |
-> ignored2 |
-> IO ByteString |
-> IO FilePath |

Same as `tempFileSink`, but use configurable temp folders and patterns.

type Param = (ByteString, ByteString)

Post parameter name and value.

type File y = (ByteString, FileInfo y)

Post parameter name and associated file information.

data FileInfo c

Information on an uploaded file.

Constructors

FileInfo |
Fields fileName :: ByteString fileContentType :: ByteString fileContent :: c

Instances

Eq c => Eq (FileInfo c) |
Show c => Show (FileInfo c) |

parseContentType :: ByteString -> (ByteString, [(ByteString, ByteString)])

Parse a content type value, turning a single `ByteString` into the actual content type and a list of pairs of attributes.

Since 1.3.2