mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Rename getRootRouter to getRootApp for clarity in HTTP node handling
This commit is contained in:
		@@ -71,11 +71,11 @@ module.exports = function(RED) {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function getRootRouter(app) {
 | 
					    function getRootApp(app) {
 | 
				
			||||||
        if (typeof app.parent === 'undefined') {
 | 
					        if (typeof app.parent === 'undefined') {
 | 
				
			||||||
            return app;
 | 
					            return app;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return getRootRouter(app.parent)
 | 
					        return getRootApp(app.parent)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function createRouteId(req) {
 | 
					    function createRouteId(req) {
 | 
				
			||||||
@@ -83,7 +83,7 @@ module.exports = function(RED) {
 | 
				
			|||||||
        return `${method}:${url}`;
 | 
					        return `${method}:${url}`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var rootApp = getRootRouter(RED.httpNode)
 | 
					    var rootApp = getRootApp(RED.httpNode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check if middleware already exists
 | 
					    // Check if middleware already exists
 | 
				
			||||||
    var isMiddlewarePresent = rootApp._router.stack.some(layer => layer.name === 'setupRawBodyCapture')
 | 
					    var isMiddlewarePresent = rootApp._router.stack.some(layer => layer.name === 'setupRawBodyCapture')
 | 
				
			||||||
@@ -352,10 +352,10 @@ module.exports = function(RED) {
 | 
				
			|||||||
                RED.httpNode.delete(this.url, cookieParser(), httpMiddleware, corsHandler, metricsHandler, jsonParser, urlencParser, rawBodyParser, this.callback, this.errorHandler);
 | 
					                RED.httpNode.delete(this.url, cookieParser(), httpMiddleware, corsHandler, metricsHandler, jsonParser, urlencParser, rawBodyParser, this.callback, this.errorHandler);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // unique id for httpInNodeSettings based on method name and url path
 | 
					            // unique id for httpInNode based on method name and url path
 | 
				
			||||||
            var httpInNodeId = createRouteId({url: this.url, method: this.method})
 | 
					            var httpInNodeId = createRouteId({url: this.url, method: this.method})
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // get httpInNodeSettings from RED.httpNode
 | 
					            // get httpInNode from RED.httpNode
 | 
				
			||||||
            var httpInNodes = rootApp.get('httpInNodes')
 | 
					            var httpInNodes = rootApp.get('httpInNodes')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Add httpInNode to RED.httpNode
 | 
					            // Add httpInNode to RED.httpNode
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user