changed the url to /feed/ and reject everything else

This commit is contained in:
Martin Donnelly 2018-06-13 22:14:28 +01:00
parent 636a02d04d
commit 0a587fb804

View File

@ -151,7 +151,35 @@ function getUrl (req, res) {
});
}
app.get('/:encoded_id', getUrl);
function notFound(request, response) {
logger.warn(
'Unhandled resource',
{
'statusCode': 404,
'error': 'Unknown resource',
'resource': request.originalUrl
}
);
return response
.status(404);
}
function defaultErrorHandler(error, request, response, next) {
logger.error('Uncaught error', { 'statusCode': 500, error });
return response
.status(500)
.render('pages/error');
}
app.get('/feed/:encoded_id', getUrl);
// Mount 404 handler as penultimate middleware
// app.use(notFoundHandler);
// Final middleware is our catch-all error handler
app.use(defaultErrorHandler);
const server = app.listen(port, () => {
logger.info(`Server listening on port ${port}`);