forked from asm-products/firesize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
36 lines (28 loc) · 847 Bytes
/
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
package main
import (
"log"
"net/http"
"os"
"github.com/asm-products/firesize/app/models"
"github.com/asm-products/firesize/controllers"
"github.com/asm-products/firesize/templates"
"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"))
r := mux.NewRouter()
r.SkipClean(true) // have to use whatupdave/mux until Gorilla supports this
new(controllers.HomeController).Init(r)
new(controllers.SessionsController).Init(r)
new(controllers.RegistrationsController).Init(r)
new(controllers.ImagesController).Init(r)
r.PathPrefix("/").Handler(http.FileServer(http.Dir("static")))
log.Printf("listening on %s:%s \n", host, port)
log.Fatalln(http.ListenAndServe(host+":"+port, r))
}