-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.go
57 lines (46 loc) · 1.13 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"os"
"github.com/tejo/boxed/dropbox"
)
//config struct used for configure boxed
type Config struct {
DefaultUserEmail string
HostWithProtocol string
CallbackURL string
WebHookURL string
Port string
SiteName string
AppToken dropbox.AppToken
}
var config *Config
func init() {
// initialize some config var
config = &Config{}
config.SiteName = os.Getenv("SITE_NAME")
config.DefaultUserEmail = os.Getenv("DEFAULT_USER_EMAIL")
config.AppToken = dropbox.AppToken{
Key: os.Getenv("KEY"),
Secret: os.Getenv("SECRET"),
}
if os.Getenv("HOST_WITH_PROTOCOL") != "" {
config.HostWithProtocol = os.Getenv("HOST_WITH_PROTOCOL")
} else {
config.HostWithProtocol = "http://localhost:8080"
}
if os.Getenv("WEBHOOK_URL") != "" {
config.WebHookURL = os.Getenv("WEBHOOK_URL")
} else {
config.WebHookURL = "/webhook"
}
if os.Getenv("CALLBACK_URL") != "" {
config.CallbackURL = os.Getenv("CALLBACK_URL")
} else {
config.CallbackURL = "/oauth/callback"
}
if os.Getenv("PORT") != "" {
config.Port = ":" + os.Getenv("PORT")
} else {
config.Port = ":8080"
}
}