-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfig.go
More file actions
34 lines (27 loc) · 700 Bytes
/
config.go
File metadata and controls
34 lines (27 loc) · 700 Bytes
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
package main
import (
"encoding/hex"
"github.com/JeremyLoy/config"
"github.com/gorilla/sessions"
)
type ConfigData struct {
CookieSecret string `config:"MASHER_COOKIE_SECRET"`
DBPath string `config:"MASHER_DB_PATH"`
StaticRoot string `config:"MASHER_STATIC_ROOT"`
Port int `config:"MASHER_PORT"`
}
var MasherConfig ConfigData
func LoadConfig(file string) {
err := config.From("config/masher.config").FromEnv().To(&MasherConfig)
if err != nil {
panic(err)
}
}
var SessionStore *sessions.CookieStore
func InitSession() {
secret, err := hex.DecodeString(MasherConfig.CookieSecret)
if err != nil {
panic(err)
}
SessionStore = sessions.NewCookieStore(secret)
}