Unify oss and internal version of base body loader middleware
Reviewed By: @amasad Differential Revision: D2519637 fb-gh-sync-id: 88f23c33a1ca0423852ce8ed7696df811e3f8d27
This commit is contained in:
parent
0a835b7994
commit
42d756310a
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
module.exports = function(req, res, next) {
|
||||
req.rawBody = '';
|
||||
req.setEncoding('utf8');
|
||||
|
||||
req.on('data', function(chunk) {
|
||||
req.rawBody += chunk;
|
||||
});
|
||||
|
||||
req.on('end', function() {
|
||||
next();
|
||||
});
|
||||
};
|
|
@ -21,6 +21,7 @@ const cpuProfilerMiddleware = require('./cpuProfilerMiddleware');
|
|||
const connect = require('connect');
|
||||
const formatBanner = require('./formatBanner');
|
||||
const getDevToolsMiddleware = require('./getDevToolsMiddleware');
|
||||
const loadRawBodyMiddleware = require('./loadRawBodyMiddleware');
|
||||
const openStackFrameInEditorMiddleware = require('./openStackFrameInEditorMiddleware');
|
||||
const parseCommandLine = require('./parseCommandLine.js');
|
||||
const ReactPackager = require('./react-packager');
|
||||
|
@ -157,19 +158,6 @@ var server = runServer(options, function() {
|
|||
|
||||
webSocketProxy.attachToServer(server, '/debugger-proxy');
|
||||
|
||||
function loadRawBody(req, res, next) {
|
||||
req.rawBody = '';
|
||||
req.setEncoding('utf8');
|
||||
|
||||
req.on('data', function(chunk) {
|
||||
req.rawBody += chunk;
|
||||
});
|
||||
|
||||
req.on('end', function() {
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
function getAppMiddleware(options) {
|
||||
var transformerPath = options.transformer;
|
||||
if (!isAbsolutePath(transformerPath)) {
|
||||
|
@ -198,7 +186,7 @@ function runServer(
|
|||
readyCallback
|
||||
) {
|
||||
var app = connect()
|
||||
.use(loadRawBody)
|
||||
.use(loadRawBodyMiddleware)
|
||||
.use(getDevToolsMiddleware(options))
|
||||
.use(openStackFrameInEditorMiddleware)
|
||||
.use(statusPageMiddleware)
|
||||
|
|
Loading…
Reference in New Issue