-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (36 loc) · 1.03 KB
/
main.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
package main
import (
"encoding/json"
"os"
"projects/blog/dataservice"
"projects/blog/helpers"
"projects/blog/routers"
)
func main() {
// Conect DB here
// Load the configuration file
helpers.Load("dataservice"+string(os.PathSeparator)+"configDB.json", config)
// Configure the session cookie store
helpers.Configure(config.Session)
// Connect to database
dataservice.InitDb(config.Database)
// Run server
start := routers.GetRouter()
if !start {
panic("error. Cannot start server")
}
}
// *****************************************************************************
// Application Settings
// *****************************************************************************
// config the settings variable
var config = &configuration{}
// configuration contains the application settings
type configuration struct {
Database dataservice.Info `json:"Database"`
Session helpers.Session `json:"Session"`
}
// ParseJSON unmarshals bytes to structs
func (c *configuration) ParseJSON(b []byte) error {
return json.Unmarshal(b, &c)
}