This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Description
🚀 Feature Proposal
Currently for POST actions fast-proxy support plain/text and application/json.
Motivation
Adding support for additional application/x-www-form-urlencoded
Example
curl -i -H "content-type: application/x-www-form-urlencoded" -X POST -d 'a=1' http://localhost:4000/api/v1/service
Handling the body is likewise:
if (req.body instanceof Stream) {
body = req.body
} else if (typeof req.body === 'string') {
body = req.body
populateHeaders(headers, body, 'text/plain')
} else {
body = JSON.stringify(req.body)
populateHeaders(headers, body, 'application/x-www-form-urlencoded')
}
It should be:
const qs = require('querystring')
if (req.body instanceof Stream) {
body = req.body
} else if (typeof req.body === 'string') {
body = req.body
populateHeaders(headers, body, 'text/plain')
} else if (headers['content-type'] === 'application/x-www-form-urlencoded') {
const qs = require('querystring');
body = qs.stringify(req.body)
populateHeaders(headers, body, 'application/x-www-form-urlencoded')
} else {
body = JSON.stringify(req.body)
populateHeaders(headers, body, 'application/x-www-form-urlencoded')
}