-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (38 loc) · 772 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
package main
import (
"github.com/jub3i/go-webserver/config"
"github.com/jub3i/go-webserver/routes"
"github.com/jub3i/go-webserver/services/session"
"log"
"net/http"
"os"
)
func main() {
// config init
c, err := config.Init([]string{
"GOWS_PORT",
"GOWS_SESSION_STORE_KEY",
"GOWS_ENV",
})
if err != nil {
log.Fatal(err)
}
log.Printf("go-webserver mode: %s", c["GOWS_ENV"])
// session init
secure := false
if os.Getenv("GOWS_ENV") == "prod" {
secure = true
}
err = session.Init(
"sid",
os.Getenv("GOWS_SESSION_STORE_KEY"),
secure,
)
if err != nil {
log.Fatal(err)
}
// start the http server
addr := "localhost:" + os.Getenv("GOWS_PORT")
log.Printf("starting go-webserver on `%s`", addr)
http.ListenAndServe(addr, routes.Mux)
}