-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (32 loc) · 828 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
44
package handler //for vercel
// package main
import (
"log"
"net/http"
"github.com/fauzancodes/yugioh-open-api/app/config"
"github.com/fauzancodes/yugioh-open-api/app/middlewares"
"github.com/fauzancodes/yugioh-open-api/app/routes"
_ "github.com/joho/godotenv/autoload"
"github.com/labstack/echo/v4"
)
func main() {
app := Init()
port := config.LoadConfig().Port
log.Printf("Server: " + config.LoadConfig().BaseUrl + ":" + port)
app.Logger.Fatal(app.Start(":" + port))
}
func Main(w http.ResponseWriter, r *http.Request) {
e := Init()
e.ServeHTTP(w, r)
}
func Init() *echo.Echo {
app := echo.New()
app.Use(middlewares.Cors())
app.Use(middlewares.Gzip())
app.Use(middlewares.Logger())
app.Use(middlewares.Secure())
app.Use(middlewares.Recover())
config.Database()
routes.Route(app)
return app
}