We have a POST API which accepts bytes in the request body.
Edgemicro is not able to pass the request body to the backend service.
In my Custom plugin, I have already overridden "ondata_request" and "onend_request" functions.
Please find the below custom plugin
'use strict'; var debug = require('debug')('plugin:wpp_avatar_clientid'); module.exports.init = function(config, logger, stats) { function accumulate(req, data) { if (!req._chunks) req._chunks = []; req._chunks.push(data); } debug('>>init()'); return { onrequest: function(req, res, next) { debug("ClientID: " + req.headers['x-clientid']); if(req.headers['x-clientid']) { req.headers['x-api-key'] = req.headers['x-clientid']; } else { req.headers['x-api-key'] = "<%="#{node['rp_service']['apigee_avprt_default_app_key']}"%>"; } debug('x-api-key: ' + req.headers['x-api-key']); next(); }, ondata_request: function(req, res, data, next) { debug('plugin ondata_request ' + data.length); if (data && data.length > 0) accumulate(req, data); next(null, data); }, onend_request: function(req, res, data, next) { if (data && data.length > 0) accumulate(req, data); var content = null; if (req._chunks && req._chunks.length) { content = Buffer.concat(req._chunks); } delete req._chunks; next(null, content); }, onclose_request: function(req, res, next) { debug('plugin onclose_request'); next(); }, ondata_response: function(req, res, data, next) { debug('>>ondata_response() ' + data.length); next(null, data); }, onend_response: function(req, res, data, next) { debug('***** plugin onend_response'); next(null, data); } }; debug('<<init()'); }
Are you using the provided plugin from here?
If you have customized it, let us know what you have done and what you wanted to achieve. Also, if you could provide your code in a
code block
that would make it much easier to read 🙂
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |