-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
46 lines (40 loc) · 956 Bytes
/
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
44
45
46
package main
import (
"crypto/tls"
"fmt"
"github.com/hoisie/web"
)
func main() {
c, err := LoadConfig("./conf.yaml")
if err != nil {
fmt.Println("Error loading config file:", err)
}
//setup server and handlers
server := web.NewServer()
te, err := NewThemeEngine()
if err != nil {
fmt.Println("Error creating theme engine:", err)
return
}
controller := Controller{themeEngine: te, articlesPerPage: c.ArticlesPerPage}
controller.Init(c, server)
te.Run()
switch c.Protocol {
case "https":
//setup for https
config := tls.Config{
Time: nil,
}
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(c.Certfile, c.Keyfile)
if err != nil {
fmt.Println("error, could not load ssl cert and/or key")
return
}
server.RunTLS(c.Address+":"+c.Port, &config)
case "http":
server.Run(c.Address + ":" + c.Port)
case "fcgi":
server.RunFcgi(c.Address + ":" + c.Port)
}
}