Last change
on this file since 140 was 140, checked in by Izuru Yakumo, 2 years ago |
Incorporate most of the open pull requests found on GitHub
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
1.0 KB
|
Rev | Line | |
---|
[127] | 1 | package config
|
---|
| 2 |
|
---|
| 3 | import (
|
---|
| 4 | "os"
|
---|
| 5 | )
|
---|
| 6 |
|
---|
| 7 | type Config struct {
|
---|
| 8 | Debug bool
|
---|
| 9 | ListenAddress string
|
---|
| 10 | Key string
|
---|
| 11 | IPV6 bool
|
---|
| 12 | RequestTimeout uint
|
---|
[131] | 13 | FollowRedirect bool
|
---|
[140] | 14 | MaxConnsPerHost uint
|
---|
| 15 | UrlParameter string
|
---|
| 16 | HashParameter string
|
---|
[127] | 17 | }
|
---|
| 18 |
|
---|
| 19 | var DefaultConfig *Config
|
---|
| 20 |
|
---|
| 21 | func init() {
|
---|
| 22 | default_listen_addr := os.Getenv("MORTY_ADDRESS")
|
---|
| 23 | if default_listen_addr == "" {
|
---|
| 24 | default_listen_addr = "127.0.0.1:3000"
|
---|
| 25 | }
|
---|
[140] | 26 | default_url_parameter := os.Getenv("MORTY_URL_PARAM")
|
---|
| 27 | if default_url_parameter == "" {
|
---|
| 28 | default_url_parameter = "mortyurl"
|
---|
| 29 | }
|
---|
| 30 | default_hash_parameter := os.Getenv("MORTY_HASH_PARAM")
|
---|
| 31 | if default_hash_parameter == "" {
|
---|
| 32 | default_hash_parameter = "mortyhash"
|
---|
| 33 | }
|
---|
[127] | 34 | default_key := os.Getenv("MORTY_KEY")
|
---|
| 35 | DefaultConfig = &Config{
|
---|
| 36 | Debug: os.Getenv("DEBUG") != "false",
|
---|
| 37 | ListenAddress: default_listen_addr,
|
---|
| 38 | Key: default_key,
|
---|
| 39 | IPV6: true,
|
---|
| 40 | RequestTimeout: 5,
|
---|
[131] | 41 | FollowRedirect: false,
|
---|
[140] | 42 | MaxConnsPerHost: 4,
|
---|
| 43 | UrlParameter: default_url_parameter,
|
---|
| 44 | HashParameter: default_hash_parameter,
|
---|
[127] | 45 | }
|
---|
| 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.