-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·29 lines (25 loc) · 767 Bytes
/
main.go
File metadata and controls
executable file
·29 lines (25 loc) · 767 Bytes
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
package main
import (
"github.com/AidHamza/optimizers-api/config"
"github.com/AidHamza/optimizers-api/log"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
err := config.App.Init()
if err != nil {
log.Logger.Error("Cannot load app configuration", "VIPER_ERROR", err.Error())
}
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.RequestID())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{config.App.Service.CrossOrigin},
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
}))
e.POST("/crunch", func(c echo.Context) error {
return cruncher(c)
})
e.Logger.Fatal(e.Start(":" + config.App.Service.Port))
}