From 7d5116f6f6096a9f37c4c71635dc570b7048c992 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 2 Jul 2012 10:35:31 +0200 Subject: o Adding support for employee name query. --- app.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 6f3f4cf..dcbfb95 100644 --- a/app.js +++ b/app.js @@ -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; -- cgit v1.2.3