Why these 2 calls to same function?
-
26-12-2019 - |
Вопрос
I'm looking at GhostJS source code for learning Nodejs. I didn't understand why these 2 calls with different params for the same function:
Anyone could explain why that?
Thanks =D
EDIT: This is the code at time of writing:
server.use('/ghost/upload/', express.multipart());
server.use('/ghost/upload/', express.multipart({uploadDir: __dirname + '/content/images'}));
EDIT 2 See this github issue: https://github.com/TryGhost/Ghost/issues/1511
Решение
Can be traced back to the first commit for this file, where bodyParser()
was used.
This adds two middlewares. The first multipart
middleware will flag the body
as parsed and do what it has to do:
req._body = true;
... and in the second run, the middleware won't do anything, as the body is already parsed:
return function multipart(req, res, next) {
if (req._body) return next();
...
}
This looks like a mistake to me.
Не связан с StackOverflow