Everything should be made as simple as possible, but not simpler
const { createHandler, buffer } = require('async-handler')
/**
* A simple echo server...
*
* Buffers the request body and
* sends it back.
*/
const fn = async function (req) {
const content = await buffer(req)
return content
}
const handler = createHandler(fn)
/**
* Or you could just send the request as
* the response (piped under the hood).
*/
const piper = createHandler(asnyc req => req)
WIP: probably not ready
createHandler(fn[, catcher])
-
fn (
function
) -
catcher (
function
)
buffer(incomingMessage[, limit])
-
incomingMessage (
object
) - anhttp.incomingMessage
-
limit (
number
) - defaults to1000000
© axdg • (axdg@dfant.asia) • 2017