diff options
author | tv <tv@nomic.retiolum> | 2014-01-06 01:38:37 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2014-01-06 01:38:37 +0100 |
commit | 7023ea2453bde5a09ffd2555c4237443ad88b643 (patch) | |
tree | d4a58459876213df55ba9d888bc5b5cde95ab8bc /go | |
parent | 1915e77f5d97f9a2816c447e3051d63d18a8b71d (diff) |
go: make URI_PREFIX configurable
Diffstat (limited to 'go')
-rw-r--r-- | go/README.markdown | 3 | ||||
-rw-r--r-- | go/etc/conf.d/go.env | 1 | ||||
-rw-r--r-- | go/index.js | 20 |
3 files changed, 16 insertions, 8 deletions
diff --git a/go/README.markdown b/go/README.markdown index e21a132d..56378151 100644 --- a/go/README.markdown +++ b/go/README.markdown @@ -12,10 +12,11 @@ ## run service - HOSTN=go PORT=80 node . + HOSTN=go PORT=80 URI_PREFIX=http://go node . if you omit `HOSTN`, then relative shortened uris will be generated. if you omit `PORT`, then it's `1337`. + if you omit `URI_PREFIX`, then it will be generated from `HOSTN` änd `PORT`. ## add uri diff --git a/go/etc/conf.d/go.env b/go/etc/conf.d/go.env index 1767ffce..1b8c980b 100644 --- a/go/etc/conf.d/go.env +++ b/go/etc/conf.d/go.env @@ -1,2 +1,3 @@ HOSTN=go PORT=1337 +URI_PREFIX=http://go diff --git a/go/index.js b/go/index.js index 16b6df98..44ff79b5 100644 --- a/go/index.js +++ b/go/index.js @@ -1,15 +1,21 @@ -// configuration (and defaults) +// configuration var hostname = process.env.HOSTN; -var httpPort = process.env.PORT || 1337; +var httpPort = process.env.PORT; +var uriPrefix = process.env.URI_PREFIX; var redisPrefix = 'go:'; // automatic configuration -var uriPrefix = ''; -if (hostname) { - uriPrefix += 'http://' + hostname; - if (httpPort != 80) { - uriPrefix += ':' + httpPort; +if (!httpPort) { + httpPort = 1337; +} +if (!uriPrefix) { + uriPrefix = ''; + if (hostname) { + uriPrefix += 'http://' + hostname; + if (httpPort != 80) { + uriPrefix += ':' + httpPort; + } } } |