-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
111 lines (100 loc) · 3.16 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package config
import (
"os"
"github.com/jinzhu/configor"
amazonpay "github.com/qor/amazon-pay-sdk-go"
"github.com/qor/auth/providers/facebook"
"github.com/qor/auth/providers/github"
"github.com/qor/auth/providers/google"
"github.com/qor/auth/providers/twitter"
"github.com/qor/gomerchant"
"github.com/qor/location"
"github.com/qor/mailer"
"github.com/qor/mailer/logger"
"github.com/qor/media/oss"
"github.com/qor/oss/s3"
"github.com/qor/redirect_back"
"github.com/qor/session/manager"
"github.com/unrolled/render"
)
type SMTPConfig struct {
Host string
Port string
User string
Password string
}
var Config = struct {
HTTPS bool `default:"false" env:"HTTPS"`
Port uint `default:"7000" env:"PORT"`
DB struct {
Name string `env:"DBName" default:"qor_example"`
Adapter string `env:"DBAdapter" default:"mysql"`
Host string `env:"DBHost" default:"localhost"`
Port string `env:"DBPort" default:"3306"`
User string `env:"DBUser"`
Password string `env:"DBPassword"`
}
S3 struct {
AccessKeyID string `env:"AWS_ACCESS_KEY_ID"`
SecretAccessKey string `env:"AWS_SECRET_ACCESS_KEY"`
Region string `env:"AWS_Region"`
S3Bucket string `env:"AWS_Bucket"`
}
AmazonPay struct {
MerchantID string `env:"AmazonPayMerchantID"`
AccessKey string `env:"AmazonPayAccessKey"`
SecretKey string `env:"AmazonPaySecretKey"`
ClientID string `env:"AmazonPayClientID"`
ClientSecret string `env:"AmazonPayClientSecret"`
Sandbox bool `env:"AmazonPaySandbox"`
CurrencyCode string `env:"AmazonPayCurrencyCode" default:"JPY"`
}
SMTP SMTPConfig
Github github.Config
Google google.Config
Facebook facebook.Config
Twitter twitter.Config
GoogleAPIKey string `env:"GoogleAPIKey"`
BaiduAPIKey string `env:"BaiduAPIKey"`
}{}
var (
Root = os.Getenv("GOPATH") + "/src/github.com/qor/qor-example"
Mailer *mailer.Mailer
Render = render.New()
AmazonPay amazonpay.AmazonPayService
PaymentGateway gomerchant.PaymentGateway
RedirectBack = redirect_back.New(&redirect_back.Config{
SessionManager: manager.SessionManager,
IgnoredPrefixes: []string{"/auth"},
})
)
func init() {
if err := configor.Load(&Config, "config/database.yml", "config/smtp.yml", "config/application.yml"); err != nil {
panic(err)
}
location.GoogleAPIKey = Config.GoogleAPIKey
location.BaiduAPIKey = Config.BaiduAPIKey
if Config.S3.AccessKeyID != "" {
oss.Storage = s3.New(&s3.Config{
AccessID: Config.S3.AccessKeyID,
AccessKey: Config.S3.SecretAccessKey,
Region: Config.S3.Region,
Bucket: Config.S3.S3Bucket,
})
}
AmazonPay = amazonpay.New(&amazonpay.Config{
MerchantID: Config.AmazonPay.MerchantID,
AccessKey: Config.AmazonPay.AccessKey,
SecretKey: Config.AmazonPay.SecretKey,
Sandbox: true,
Region: "jp",
})
// dialer := gomail.NewDialer(Config.SMTP.Host, Config.SMTP.Port, Config.SMTP.User, Config.SMTP.Password)
// sender, err := dialer.Dial()
// Mailer = mailer.New(&mailer.Config{
// Sender: gomailer.New(&gomailer.Config{Sender: sender}),
// })
Mailer = mailer.New(&mailer.Config{
Sender: logger.New(&logger.Config{}),
})
}