aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 5be5f687cc65df1010644e0dd23ca574816a1fb6 (plain)
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
47
package main

import (
//	"log"
	"net/http"
	"os"

	"github.com/gin-gonic/gin"
	_ "github.com/heroku/x/hmetrics/onload"
)

func main() {
	port := os.Getenv("PORT")

	if port == "" {
	//	log.Fatal("$PORT must be set")
		port = "8080"
	}

	router := gin.New()
	router.Use(gin.Logger())
	router.LoadHTMLGlob("templates/*")
	router.Static("/static", "static")
	router.Static("/media", "media")

	router.GET("/en", func(c *gin.Context) {
		c.HTML(http.StatusOK, "en.index.html", nil)
	})

	router.GET("/jp", func(c *gin.Context) {
		c.HTML(http.StatusOK, "jp.index.html", nil)
	})

	router.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "redirect.index.html", nil)
	})

	router.GET("/new", func(c *gin.Context) {
		c.HTML(http.StatusOK, "new.index.html", nil)
	})

	router.GET("/site-down", func(c *gin.Context) {
		c.HTML(http.StatusOK, "maintain.html", nil)
	})

	router.Run(":" + port)
}