summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--go/README.markdown3
-rw-r--r--go/etc/conf.d/go.env1
-rw-r--r--go/index.js20
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;
+ }
}
}