mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 15:34:26 +01:00
Update 21-httpin.js
- change the function name - remove and change some functions description
This commit is contained in:
@@ -29,13 +29,6 @@ module.exports = function(RED) {
|
||||
var hashSum = require("hash-sum");
|
||||
var rawDataRoutes = new Set();
|
||||
|
||||
/**
|
||||
* This middleware parses the raw body if the user enables it.
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} _res
|
||||
* @param {import('express').NextFunction} next
|
||||
* @returns
|
||||
*/
|
||||
function rawBodyParser(req, res, next) {
|
||||
if (req.skipRawBodyParser) { next(); } // don't parse this if told to skip
|
||||
if (req._body) { return next(); }
|
||||
@@ -105,13 +98,13 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This middleware is for clone the request stream
|
||||
* This middleware is for capture raw body
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} _res
|
||||
* @param {import('express').NextFunction} next
|
||||
* @returns
|
||||
*/
|
||||
function setupRawBodyCapture(req, _res, next) {
|
||||
function rawBodyCapture(req, _res, next) {
|
||||
var routeKey = getRouteKey({ method: req.method, url: req._parsedUrl.pathname });
|
||||
// Check if routeKey exist in rawDataRoutes
|
||||
if (rawDataRoutes.has(routeKey)) {
|
||||
@@ -135,7 +128,7 @@ module.exports = function(RED) {
|
||||
|
||||
if(typeof RED.httpNode === 'function' && (rootApp = getRootApp(RED.httpNode))) {
|
||||
// Add middleware to the stack
|
||||
rootApp.use(setupRawBodyCapture);
|
||||
rootApp.use(rawBodyCapture);
|
||||
// Move the middleware to top of the stack
|
||||
rootApp._router.stack.unshift(rootApp._router.stack.pop());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user