routing-controllers
routing-controllers copied to clipboard
A catch-all 404 handler for koa?
Hello!
I'm trying to implement a pretty trivial thing — a catch-all handler that will return 404 when request handler is not found for the request in question, however, I can't find any related examples in the docs. What is the best practice for this? I'm using koa.
If I add the following middleware, then it will overwrite the response data from the controller:
app.use(context => {
context.status = 404;
context.body = {
message: 'Not found',
};
});