This doesn't show any response to an HTTP request, just hangs:
function middleware(req, res, next) {
to_end(res).NotFound();
return next();
}
This works:
function middleware(req, res, next) {
to_end(res).NotFound();
res.send(); // <----------------------------------------------
return next();
}
I'm using restify with this simple function:
export const to_end = res => {
return {
NotFound: (entity = 'Entity') => res.json(404, {
error: 'NotFound', error_message: `${entity} not found`
})
}
}