summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorhorus_arch2015-04-21 01:47:42 +0200
committerhorus_arch2015-04-21 01:47:42 +0200
commitb3fa125ed0292f8ca37e91bf19c8cae7cdacc506 (patch)
tree61079b97ed26bf4c9483eb14dee7205c3c349b90 /main.go
parent01e9a34952bd6ddd383680b0ca2312e476ad07a6 (diff)
downloadmandible-b3fa125ed0292f8ca37e91bf19c8cae7cdacc506.tar.gz
Add API documentation and better defaults.
Diffstat (limited to 'main.go')
-rw-r--r--main.go30
1 files changed, 26 insertions, 4 deletions
diff --git a/main.go b/main.go
index 67ef2ad..e1f7e68 100644
--- a/main.go
+++ b/main.go
@@ -1,10 +1,7 @@
package main
import (
- /*
- mandibleConf "mandible/config"
- mandible "mandible/server"
- */
+ "fmt"
"mandible/config"
mandible "mandible/server"
"os"
@@ -12,8 +9,33 @@ import (
func main() {
configFile := os.Getenv("IMGUR_GO_CONF")
+ if configFile == "" {
+ configFile = "config/conf.json"
+ }
config := config.NewConfiguration(configFile)
+
+ port := ":" + os.Getenv("PORT")
+ if port == ":" {
+ port = fmt.Sprintf(":%d", config.Port)
+ }
+
+ if os.Getenv("UPLOAD_URL") == "" {
+ os.Setenv("UPLOAD_URL", "http://127.0.0.1"+port)
+ }
+
+ if os.Getenv("ORIGIN_URL") == "" {
+ os.Setenv("ORIGIN_URL", os.Getenv("UPLOAD_URL"))
+ }
+
+ if os.Getenv("STATIC_DIR") == "" {
+ os.Setenv("STATIC_DIR", (config.Stores[0]["StoreRoot"])+"/../static")
+ }
+
+ if os.Getenv("UPLOAD_DIR") == "" {
+ os.Setenv("UPLOAD_DIR", (config.Stores[0]["StoreRoot"]))
+ }
+
server := mandible.CreateServer(config)
server.Start()
}