-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
48 lines (41 loc) · 1.22 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
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
facebookauth "github.com/herb-go/herbmodule-drivers/externalauth-drivers/facebookauth"
githubauth "github.com/herb-go/herbmodule-drivers/externalauth-drivers/githubauth"
wechatmpauth "github.com/herb-go/herbmodule-drivers/externalauth-drivers/wechatmpauth"
wechatworkauth "github.com/herb-go/herbmodule-drivers/externalauth-drivers/wechatworkauth"
windowsliveauth "github.com/herb-go/herbmodule-drivers/externalauth-drivers/windowsliveauth"
)
type APPConfig struct {
Host string
Addr string
Github *githubauth.OauthAuthConfig
WechatworkOauth *wechatworkauth.OauthAuthConfig
WechatworkQR *wechatworkauth.QRAuthConfig
Windowslive *windowsliveauth.OauthAuthConfig
Wechatmp *wechatmpauth.OauthAuthConfig
Facebook *facebookauth.OauthAuthConfig
}
func (c *APPConfig) Server() *http.Server {
server := &http.Server{
Addr: c.Addr,
}
return server
}
func (c *APPConfig) MustLoadJSON(filename string) {
data, err := ioutil.ReadFile(filename)
if err != nil {
panic(err)
}
err = json.Unmarshal(data, c)
if err != nil {
panic(err)
}
}
var Config = &APPConfig{}
func init() {
Config.MustLoadJSON("config.json")
}