没有以声明方式执行此操作的机制,但可以在每个路由的基础上禁用中间件。您可以通过覆盖中间件并检查自定义代码中的路由URL来实现这一点,类似于
using a separate body parser for XML requests
.例如:
// In config/http.js `middleware` property
bodyParser: (function() {
// Initialize a skipper instance with the default options.
var skipper = require('skipper')();
// Create and return the middleware function.
return function(req, res, next) {
// If we see the route we want skipped, just continue.
if (req.url === '/dont-parse-me') {
return next();
}
// Otherwise use Skipper to parse the body.
return skipper(req, res, next);
};
})()