| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Servant.Multipart.Client
Contents
Description
multipart/form-data client-side support for servant.
See servant-multipart-api for the API definitions.
Synopsis
- genBoundary :: IO ByteString
- class ToMultipart tag a where
- toMultipart :: a -> MultipartData tag
- multipartToBody :: forall tag. MultipartClient tag => ByteString -> MultipartData tag -> RequestBody
Documentation
genBoundary :: IO ByteString Source #
Generates a boundary to be used to separate parts of the multipart.
Requires IO because it is randomized.
class ToMultipart tag a where #
Allows you to tell servant how to turn a more structured type
into a MultipartData, which is what is actually sent by the
client.
data User = User { username :: Text, pic :: FilePath }
instance toMultipart Tmp User where
toMultipart user = MultipartData [Input "username" $ username user]
[FileData "pic"
(pic user)
"image/png"
(pic user)
]
Methods
toMultipart :: a -> MultipartData tag #
Given a value of type a, convert it to a
MultipartData.
Instances
| ToMultipart tag (MultipartData tag) | |
Defined in Servant.Multipart.API Methods toMultipart :: MultipartData tag -> MultipartData tag # | |
multipartToBody :: forall tag. MultipartClient tag => ByteString -> MultipartData tag -> RequestBody Source #
Given a bytestring for the boundary, turns a MultipartData into
a RequestBody
Orphan instances
| (ToMultipart tag a, HasClient m api, MultipartClient tag) => HasClient m (MultipartForm' mods tag a :> api) Source # | Upon seeing |
Associated Types type Client m (MultipartForm' mods tag a :> api) # Methods clientWithRoute :: Proxy m -> Proxy (MultipartForm' mods tag a :> api) -> Request -> Client m (MultipartForm' mods tag a :> api) # hoistClientMonad :: Proxy m -> Proxy (MultipartForm' mods tag a :> api) -> (forall x. mon x -> mon' x) -> Client mon (MultipartForm' mods tag a :> api) -> Client mon' (MultipartForm' mods tag a :> api) # | |