app.get("/application/status", function(request, response) {
		// Return status of the server.
		
		// There is no path through 'serv' right now so we communicate
		// direct with the server it starts (see URL)
		var mimeclient = mime();
		
		mimeclient({ path:url+"/serv/status", method:"GET" }).then(function(status_response) {
				response.send({"status": "running", "path": status_response.entity.path},200);
			},function(error) {
				response.send({"status":"not running"},200);
			});
	});
function configure(options) {

	var token = options.token;
	if (!token) {
		throw new Error('github-rest-client needs to be configured with an OAuth token');
	}

	var rest = require('rest');
//	var basicAuth = require('rest/interceptor/basicAuth');
	var interceptor = require('rest/interceptor');
	var errorCode = require('rest/interceptor/errorCode');
	var entity = require('rest/interceptor/entity');
	var mime = require('rest/interceptor/mime');
	var retry = require('rest/interceptor/retry');
	var when = require('when');


	var oauth = interceptor({
		request: function (request, config) {
			var headers = request.headers || (request.headers = {});
			headers.Authorization = "token " + token;
			return request;
		}
	});

//	var redirect = interceptor({
//		//See http://developer.github.com/v3/#http-redirects
//		response: function (resp) {
//			if (resp.status && resp.status.code === 301) {
//				console.log('Request for : '+resp.request.path);
//				console.log('Should redirect to : '+resp.headers.Location);
//			}
//			return resp;
//		}
//	});

	var logResp = interceptor({
		response: function (resp) {
			console.dir(resp);
			return resp;
		}
	});

	var logRateLimit = interceptor({
		response: function (resp) {
			var limit = deref(resp, ['headers', 'X-Ratelimit-Limit']);
			if (limit) {
				var remaining = deref(resp, ['headers', 'X-Ratelimit-Remaining']);
				if (remaining%100===0 || remaining < 100) {
					console.log('github rate limit: '+remaining+ '/'+ limit + ' url: '+resp.request.path);
				}
			}
//			var mem = process.memoryUsage();
//			console.log('mem = '+JSON.stringify(mem));
			return resp;
		}
	});

	function fixNoExistError(client) {
		return function () {
			var args = Array.prototype.slice.call(arguments);
			return client.apply(this, arguments).otherwise(function (err) {
				if (err && err.message === 'Not Found') {
					return when.reject(fsErrors.noExistError('github-rest-client', args[0].path));
				}
				return when.reject(err);
			});
		};
	}

	var oauthClient = fixNoExistError(errorCode(mime(logRateLimit(oauth()))));

	return oauthClient;

}