forked from nohaapav/docker-napp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.js
25 lines (22 loc) · 791 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var os = require("os");
var util = require("util");
var http = require("http");
var appRouter = function (app) {
app.get("/", function (req, res) {
var result = util.format("I'm %s \n", os.hostname());
res.send(result);
});
app.get('/redirect/:service', function (req, res) {
var serviceName = req.params.service
var serviceUrl = ["http://", serviceName, ":", 8080];
var url = serviceUrl.join("");
var response
http.get(url, function (response) {
response.on('data', function (chunk) {
var result = util.format("Redirecting from [%s] to %s \nResponse: %s", os.hostname(), url, chunk);
res.send(result);
});
}).end();
});
}
module.exports = appRouter;