【发布时间】:2016-02-12 03:21:54
【问题描述】:
这不会显示对 HTTP 请求的任何响应,只是挂起:
function middleware(req, res, next) {
to_end(res).NotFound();
return next();
}
这行得通:
function middleware(req, res, next) {
to_end(res).NotFound();
res.send(); // <----------------------------------------------
return next();
}
我正在使用带有这个简单功能的 restify:
export const to_end = res => {
return {
NotFound: (entity = 'Entity') => res.json(404, {
error: 'NotFound', error_message: `${entity} not found`
})
}
}
【问题讨论】:
标签: javascript node.js parameter-passing connect restify