Commit d0a827b6d0f092e5a0d85b519f28bbfea1fb95a3
1 parent
06133cd9
404, 405, 406, 418...
Toujours pas possible de gérer le 404 serveur sans partager un fichier commun entre le client et le serveur avec la liste des pages.
Showing
3 changed files
with
21 additions
and
3 deletions
Show diff stats
app/routes.js
... | ... | @@ -6,7 +6,17 @@ module.exports = function (app) { |
6 | 6 | app.use('/api/', api); |
7 | 7 | |
8 | 8 | app.get('*', function (req, res) { |
9 | - res.sendFile('public/views/index.html', { root: path.normalize(__dirname + '/..') }); | |
9 | + if (req.accepts('text/html')) { | |
10 | + res.sendFile('public/views/index.html', { | |
11 | + root: path.normalize(__dirname + '/..') | |
12 | + }); | |
13 | + } else { | |
14 | + res.send(404).end(); | |
15 | + } | |
16 | + }); | |
17 | + | |
18 | + app.all('*', function (req, res) { | |
19 | + res.send(405).end(); | |
10 | 20 | }); |
11 | 21 | |
12 | 22 | }; | ... | ... |
app/routes/ApiRtes.js
... | ... | @@ -229,7 +229,12 @@ api.delete('/messs/:mess_id', reqPerm('canDelMess'), function (req, res) { // Su |
229 | 229 | }); |
230 | 230 | }); |
231 | 231 | |
232 | -// TODO 404 | |
233 | -// TODO 418 | |
232 | +api.all('/coffee', function (req, res) { | |
233 | + res.status(418).end(); | |
234 | +}); | |
235 | + | |
236 | +api.all('*', function (req, res) { | |
237 | + res.status(405).end(); | |
238 | +}); | |
234 | 239 | |
235 | 240 | module.exports = api; | ... | ... |
public/js/app.js
... | ... | @@ -22,6 +22,9 @@ angular.module('ciApp', ['ngAnimate', 'ngRoute', 'ConnectCtrl', 'MembreCtrl', 'F |
22 | 22 | .when('/connect', { |
23 | 23 | templateUrl: 'views/connect.html', |
24 | 24 | controller: 'ConnectCtrl' |
25 | + }) | |
26 | + .otherwise({ | |
27 | + redirectTo: '/' | |
25 | 28 | }); |
26 | 29 | $locationProvider.html5Mode(true); |
27 | 30 | } | ... | ... |