-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (34 loc) · 1.11 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
package main
import (
"net/http"
"github.com/SanjaySinghRajpoot/fileSync/config"
"github.com/SanjaySinghRajpoot/fileSync/controller"
"github.com/SanjaySinghRajpoot/fileSync/utils"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
// connect to DB
config.ConnectDB()
//set up consumer - running it in a parallel go routine
go utils.Consumer()
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{echo.GET, echo.PUT, echo.POST, echo.DELETE},
}))
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
apiRouter := e.Group("/api/v1")
// This endpoint will be a part of the Block Service
// apiRouter.POST("/upload", controller.UploadFile)
// apiRouter.GET("/download", controller.Download)
apiRouter.GET("/version", controller.GetVersion)
apiRouter.POST("/hash", controller.CheckHash)
apiRouter.POST("/metadata", controller.Metadata)
// how to sync the files?
e.Logger.Fatal(e.Start(":8081"))
}