-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 1.05 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
package main
import (
"fmt"
"net/http"
"requestaggregator/app"
aggregatorController "requestaggregator/app/aggregator"
"requestaggregator/config"
"requestaggregator/internal/command"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
"github.com/labstack/echo/middleware"
)
func main() {
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
//CORS
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
}))
// Route => handler
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Welcome to Request Aggregator Project")
})
e.POST("/v1/query", aggregatorController.HandleGetAggregatorData)
e.POST("/v1/insert", aggregatorController.HandleInsertAggregatorData)
// Server
app.SetCommands()
command.RunApp()
appConfig := config.GetConfig()
fmt.Println("Starting server at ", appConfig.Port)
e.Run(standard.New(fmt.Sprintf(":%d", appConfig.Port)))
}