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

Safe Haskell | None

Network.Wai.Parse

Description

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

Synopsis

- parseHttpAccept :: ByteString -> [ByteString]
- parseRequestBody :: BackEnd y -> Request -> ResourceT IO ([Param], [File y])
- data RequestBodyType
  - = UrlEncoded
  - | Multipart ByteString
- getRequestBodyType :: Request -> Maybe RequestBodyType
- sinkRequestBody :: BackEnd y -> RequestBodyType -> Sink ByteString (ResourceT IO) ([Param], [File y])
- conduitRequestBody :: BackEnd y -> RequestBodyType -> Conduit ByteString (ResourceT IO) (Either Param (File y))
- type BackEnd a = ByteString -> FileInfo () -> Sink ByteString (ResourceT IO) a
- lbsBackEnd :: Monad m => ignored1 -> ignored2 -> Sink ByteString m ByteString
- tempFileBackEnd :: MonadResource m => ignored1 -> ignored2 -> Sink ByteString m FilePath
- tempFileBackEndOpts :: MonadResource m => IO FilePath -> String -> ignored1 -> ignored2 -> Sink ByteString m 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]Source

Parse the HTTP accept string to determine supported content types.

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

data RequestBodyType Source

Constructors

UrlEncoded |
Multipart ByteString |

getRequestBodyType :: Request -> Maybe RequestBodyType Source

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

conduitRequestBody :: BackEnd y -> RequestBodyType -> Conduit ByteString (ResourceT IO) (Either Param (File y))Source

type BackEnd aSource

Arguments

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

A file uploading backend. Takes the parameter name, file name, and content type, and returns a `Sink` for storing the contents.

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

Store uploaded files in memory

tempFileBackEnd :: MonadResource m => ignored1 -> ignored2 -> Sink ByteString m FilePath Source

Save uploaded files on disk as temporary files

tempFileBackEndOpts Source

Arguments

:: MonadResource m |
=> IO FilePath | get temporary directory
-> String | filename pattern
-> ignored1 |
-> ignored2 |
-> Sink ByteString m FilePath |

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

type Param = (ByteString, ByteString)Source

Post parameter name and value.

type File y = (ByteString, FileInfo y)Source

Post parameter name and associated file information.

data FileInfo c Source

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)])Source

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