-
Notifications
You must be signed in to change notification settings - Fork 36
/
server.go
46 lines (37 loc) · 1.16 KB
/
server.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 (
"math/rand"
"net/http"
"os"
"time"
"github.com/asm-products/firesize/addon"
"github.com/asm-products/firesize/controllers"
"github.com/asm-products/firesize/models"
"github.com/asm-products/firesize/templates"
"github.com/codegangsta/negroni"
"github.com/whatupdave/mux"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
host := os.Getenv("HOST")
templates.Init("templates")
models.InitDb(os.Getenv("DATABASE_URL"))
addon.Init(os.Getenv("HEROKU_ID"), os.Getenv("HEROKU_API_PASSWORD"), os.Getenv("HEROKU_SSO_SALT"))
rand.Seed(time.Now().UTC().UnixNano())
r := mux.NewRouter()
r.SkipClean(true) // have to use whatupdave/mux until Gorilla supports this
new(controllers.AccountsController).Init(r)
new(controllers.HerokuResourcesController).Init(r)
new(controllers.HomeController).Init(r)
new(controllers.ImagesController).Init(r)
new(controllers.RegistrationsController).Init(r)
new(controllers.SessionsController).Init(r)
new(controllers.SsoSessionsController).Init(r)
r.PathPrefix("/").Handler(http.FileServer(http.Dir("static")))
n := negroni.Classic()
n.UseHandler(r)
n.Run(host + ":" + port)
}