Configuration.serveHTTP()
Description
Appends a serveHTTP filter to the current pipeline layout.
A serveHTTP filter calls back user scripts to get an output HTTP response for each HTTP request found in the input stream.
- INPUT - Data stream containing HTTP requests received from the client.
- OUTPUT - Data stream containing HTTP responses to send to the client.
Syntax
pipy().pipeline().serveHTTP(new Message(head, body))pipy().pipeline().serveHTTP(request => getResponse(request))
Parameters
serveHTTP(handler)
handler
A callback function that receives a request Message and returns the corresponding response Message.
Return Value
The same Configuration object.
Example
pipy().listen(8080).serveHTTP(msg => new Message(`You requested ${msg.head.path}`))