-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
57 lines (41 loc) · 1.01 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"log"
"net/http"
"os"
_ "github.com/heroku/x/hmetrics/onload"
"github.com/labstack/echo/v4"
"github.com/ralberts/golang-starter-template/database"
"github.com/ralberts/golang-starter-template/examples"
)
func main() {
log.SetOutput(os.Stdout)
port := os.Getenv("PORT")
if port == "" {
log.Fatal("$PORT must be set")
}
dburl := os.Getenv("DATABASE_URL")
if dburl == "" {
log.Fatal("$DATABASE_URL must be set")
}
sslmode := os.Getenv("SSL_MODE")
if sslmode == "" {
// options here: https://godoc.org/github.com/lib/pq
sslmode = "require"
}
// testStr := database.Test()
// database.Connect(dburl)
db := database.Connect(dburl, sslmode)
e := echo.New()
group := "/api"
// example migration
example.Migrate(db)
example.Register(group, e)
log.Print("Done registering routes")
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
// v1 := r.Group("/api")
// auth.Register(v1.Group("/auth"))
}