From d0a827b6d0f092e5a0d85b519f28bbfea1fb95a3 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sat, 11 Apr 2015 01:42:15 +0200 Subject: [PATCH] 404, 405, 406, 418... --- app/routes.js | 12 +++++++++++- app/routes/ApiRtes.js | 9 +++++++-- public/js/app.js | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/routes.js b/app/routes.js index 8c3ff0a..0d525f2 100644 --- a/app/routes.js +++ b/app/routes.js @@ -6,7 +6,17 @@ module.exports = function (app) { app.use('/api/', api); app.get('*', function (req, res) { - res.sendFile('public/views/index.html', { root: path.normalize(__dirname + '/..') }); + if (req.accepts('text/html')) { + res.sendFile('public/views/index.html', { + root: path.normalize(__dirname + '/..') + }); + } else { + res.send(404).end(); + } + }); + + app.all('*', function (req, res) { + res.send(405).end(); }); }; diff --git a/app/routes/ApiRtes.js b/app/routes/ApiRtes.js index 3370b8f..3e04d73 100644 --- a/app/routes/ApiRtes.js +++ b/app/routes/ApiRtes.js @@ -229,7 +229,12 @@ api.delete('/messs/:mess_id', reqPerm('canDelMess'), function (req, res) { // Su }); }); -// TODO 404 -// TODO 418 +api.all('/coffee', function (req, res) { + res.status(418).end(); +}); + +api.all('*', function (req, res) { + res.status(405).end(); +}); module.exports = api; diff --git a/public/js/app.js b/public/js/app.js index 92e69d1..c99ded9 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -22,6 +22,9 @@ angular.module('ciApp', ['ngAnimate', 'ngRoute', 'ConnectCtrl', 'MembreCtrl', 'F .when('/connect', { templateUrl: 'views/connect.html', controller: 'ConnectCtrl' + }) + .otherwise({ + redirectTo: '/' }); $locationProvider.html5Mode(true); } -- libgit2 0.21.2