-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (36 loc) · 858 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
34
35
36
37
38
39
40
41
42
43
package main
import (
"net/http"
"os"
"github.com/labstack/echo/v4"
mid "github.com/labstack/echo/v4/middleware"
"github.com/traP-jp/hackathon_23_spring_14_server/handler"
"github.com/traP-jp/hackathon_23_spring_14_server/model"
)
func main() {
if err := model.Setup(); err != nil {
panic(err)
}
e := echo.New()
e.Use(mid.Logger())
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello World!")
})
api := e.Group("/api")
{
api.File("/swagger.yaml", "./document/swagger.yaml")
api.Static("/", "./document/swagger-ui/dist")
api.Any("", func(c echo.Context) error {
return c.Redirect(http.StatusFound, c.Path()+"/")
})
apiUser := api.Group("/user")
{
apiUser.GET("", handler.GetUsers)
}
}
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
e.Logger.Fatal(e.Start(":" + port))
}