diff options
| author | tv <tv@nomic.retiolum> | 2014-01-05 23:31:03 +0100 | 
|---|---|---|
| committer | tv <tv@nomic.retiolum> | 2014-01-05 23:31:03 +0100 | 
| commit | 4464409743a08903859340053bff58bd94df0ffd (patch) | |
| tree | a64ea2e6b4a105ac6f2a0ac7f2bc947d7df01fff /go/index.js | |
| parent | 1cbf273c3b74c070ebd7e65c50223f276daa26ca (diff) | |
go: setenv HOSTN to generate absolute uris
Diffstat (limited to 'go/index.js')
| -rw-r--r-- | go/index.js | 13 | 
1 files changed, 11 insertions, 2 deletions
diff --git a/go/index.js b/go/index.js index 470010a9..95ddd2ef 100644 --- a/go/index.js +++ b/go/index.js @@ -1,5 +1,13 @@ +var hostname = process.env.HOSTN;  var httpPort = process.env.PORT || 1337;  var redisPrefix = 'go:'; +var uriPrefix = ''; +if (hostname) { +  uriPrefix += 'http://' + hostname; +  if (httpPort != 80) { +    uriPrefix += ':' + httpPort; +  } +}  var http = require('http');  var formidable = require('formidable'); @@ -41,8 +49,9 @@ function create (req, res) {        var uri = fields.uri;        // TODO check uri(?) -      var shortUri = '/' + reply; -      var key = redisPrefix + shortUri; +      var shortPath = '/' + reply; +      var shortUri = uriPrefix + shortPath; +      var key = redisPrefix + shortPath;        redisClient.set(key, uri, function (error) {          if (error) {  | 
