Module
Yoga.Fastify.Om.RequestBody
- Package
- purescript-yoga-fastify-om
- Repository
- rowtype-yoga/purescript-yoga-fastify-om
#RequestBody Source
data RequestBody aSum type representing different request body formats
Handlers receive wrapped RequestBody values and pattern match on them.
Example usage: type MyRequest = { body :: JSONBody CreateUserRequest }
handler { request } = case request.body of JSONBody user -> createUser user NoBody -> error "No body provided"
Constructors
JSONBody aNoBodyFormData (Object String)TextBody StringBytesBody BufferStreamBody (ReadableStream Buffer)
Instances
(Show a) => Show (RequestBody a)
#toStrom Source
toStrom :: forall a ctx err. RequestBody a -> Strom ctx err BufferConvert a RequestBody to a Strom of Buffers for streaming processing.
- BytesBody: emits the buffer as a single chunk
- StreamBody: streams chunks from the ReadableStream
- TextBody: converts the string to a Buffer and emits it
- JSONBody/FormData/NoBody: emits nothing (empty stream)
Example: handler { request } = do let stream = toStrom request.body Strom.runFold (\acc chunk -> acc + Buffer.size chunk) 0 stream