diff options
| author | horus_arch | 2015-04-19 22:09:52 +0200 |
|---|---|---|
| committer | horus_arch | 2015-04-19 22:09:52 +0200 |
| commit | 01e9a34952bd6ddd383680b0ca2312e476ad07a6 (patch) | |
| tree | 00902575e5c271cc5d35ea65aa8795b8caeb97bc /config | |
| download | mandible-01e9a34952bd6ddd383680b0ca2312e476ad07a6.tar.gz | |
Initial commit.
Diffstat (limited to 'config')
| -rw-r--r-- | config/conf.json_ | 14 | ||||
| -rw-r--r-- | config/config.go | 34 | ||||
| -rw-r--r-- | config/default.conf.json | 14 |
3 files changed, 62 insertions, 0 deletions
diff --git a/config/conf.json_ b/config/conf.json_ new file mode 100644 index 0000000..a03249e --- /dev/null +++ b/config/conf.json_ @@ -0,0 +1,14 @@ +{ + "Port": 8080, + "MaxFileSize": 20971520, + "HashLength": 7, + "UserAgent": "Mandible", + "Stores" : [ + { + "Type" : "local", + "StoreRoot": "/home/horus/projects/golang/src/mandible/files", + "NamePathRegex" : "^([a-zA-Z0-9])([a-zA-Z0-9]).*", + "NamePathMap" : "${ImageSize}/${1}/${2}/${ImageName}" + } + ] +} diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..b1022e2 --- /dev/null +++ b/config/config.go @@ -0,0 +1,34 @@ +package config + +import ( + "encoding/json" + "fmt" + "os" +) + +type Configuration struct { + MaxFileSize int64 + HashLength int + UserAgent string + Stores []map[string]string + Port int +} + +func NewConfiguration(path string) *Configuration { + file, err := os.Open(path) + + if err != nil { + fmt.Printf("Error opening config file!") + os.Exit(-1) + } + + decoder := json.NewDecoder(file) + configuration := &Configuration{} + err = decoder.Decode(configuration) + + if err != nil { + fmt.Println("Error loading config file: ", err) + } + + return configuration +} diff --git a/config/default.conf.json b/config/default.conf.json new file mode 100644 index 0000000..0372b3d --- /dev/null +++ b/config/default.conf.json @@ -0,0 +1,14 @@ +{ + "Port": 8080, + "MaxFileSize": 20971520, + "HashLength": 7, + "UserAgent": "ImgurGo (https://github.com/gophergala/ImgurGo)", + "Stores" : [ + { + "Type" : "local", + "StoreRoot": "/Users/jarvis/imagestore", + "NamePathRegex" : "^([a-zA-Z0-9])([a-zA-Z0-9]).*", + "NamePathMap" : "${ImageSize}/${1}/${2}/${ImageName}" + } + ] +} |
