diff options
Diffstat (limited to 'routes')
-rw-r--r-- | routes/index.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/routes/index.js b/routes/index.js index 44feab4..ec57575 100644 --- a/routes/index.js +++ b/routes/index.js @@ -53,13 +53,15 @@ function after(res, callback) { } exports.index = function(req, res) { - if(req.accepts('html')) { + switch(req.accept.types.getBestMatch(["text/html", "application/vnd.collection+json"])) { + case "text/html": res.render('index', { title: 'Employee DB', urlgenerator: res.urlgenerator }); - } - else { + break; + case "application/vnd.collection+json": + default: var c = {collection: { links: [ { rel: 'departments', @@ -73,6 +75,7 @@ exports.index = function(req, res) { }}; res.contentType('application/vnd.collection+json'); res.send(JSON.stringify(collection_json.fromObject(c)), 200); + break; } }; |