diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-07-02 10:35:31 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-07-02 10:35:31 +0200 |
commit | 7d5116f6f6096a9f37c4c71635dc570b7048c992 (patch) | |
tree | e96ac4954a05660cf8e3ff70eb1d65417ab31ad7 /app.js | |
parent | f895dfeb979f1a98ea38a6a88f99ff63422d4348 (diff) | |
download | example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.gz example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.bz2 example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.tar.xz example-collection-json-db-7d5116f6f6096a9f37c4c71635dc570b7048c992.zip |
o Adding support for employee name query.
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,6 +1,7 @@ var express = require('express') , routes = require('./routes') - , http = require('http'); + , http = require('http') + , url = require('url'); var app = express(); @@ -28,18 +29,33 @@ function urlgenerator(req, res, next) { return 'http://' + host + '/'; }, - departments: function(offset) { - return 'http://' + host + '/department/' + (offset ? '?offset=' + offset : ''); + departments: function(query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/department/', + query: query + }); }, department: function(dept_no) { return 'http://' + host + '/department/' + dept_no; }, - employees_in_department: function(dept_no, offset) { - return 'http://' + host + '/department/' + dept_no + '/employees' + (offset ? '?offset=' + offset : ''); + employees_in_department: function(dept_no, query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/department/' + dept_no + '/employees', + query: query + }); }, - employees: function(offset) { - return 'http://' + host + '/employee/' + (offset ? '?offset=' + offset : ''); + employees: function(query) { + return url.format({ + protocol: 'http', + host: host, + pathname: '/employee/', + query: query + }); }, employee: function(emp_no) { return 'http://' + host + '/employee/' + emp_no; |