-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgohub.go
28 lines (22 loc) · 794 Bytes
/
gohub.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
package main
import (
"github.com/codegangsta/negroni"
"github.com/stretchr/graceful"
"time"
"log"
"net/http"
"github.com/alexkomrakov/gohub/service"
"github.com/alexkomrakov/gohub/server"
"github.com/goincremental/negroni-sessions"
"github.com/goincremental/negroni-sessions/cookiestore"
)
func main() {
config := service.GetServerConfig()
router := server.Router()
n := negroni.New(service.GetRecoveryLogger(config.Logs.Error), negroni.NewLogger(), negroni.NewStatic(http.Dir("public")))
store := cookiestore.New([]byte(config.SessionSecretKey))
n.Use(sessions.Sessions("SESSION", store))
n.UseHandler(router)
log.Println("Starting server on address " + config.Adress)
graceful.Run(config.Adress, 30*time.Second, n)
}