-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
33 lines (27 loc) · 766 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
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/josephgardner/isitcg/internal/isitcg"
)
func main() {
rules, err := isitcg.LoadRules("ingredientrules.json")
if err != nil {
panic("failed to load rules")
}
ingredients := isitcg.NewIngredientHandler(rules)
router := router(ingredients, renderer())
wwwroot := http.FileServer(http.Dir("./static/"))
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", wwwroot))
router.PathPrefix("/").Handler(wwwroot)
port, ok := os.LookupEnv("PORT")
if !ok {
port = "5000"
}
log.Printf("isitcg listening at http://0.0.0.0:%v", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", port),
handlers.CombinedLoggingHandler(os.Stdout, router)))
}