-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (40 loc) · 1.34 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
package main
import (
"ecommerce/api"
"ecommerce/database"
"ecommerce/middelwares"
"fmt"
"github.com/gin-gonic/gin"
)
func main() {
fmt.Println("Application is ready!")
gin.SetMode("debug") //debug or release
// Auto migration for the first time
database.AutoMigrate()
router := gin.Default()
// Set static path
router.Static("/static", "./static")
// Set max upload limit
router.MaxMultipartMemory = 8 << 20
// Auth Routers
router.POST("/auth/request-token", api.AuthRequestToken)
router.POST("/auth/refresh-token", api.AuthRefreshToken)
router.POST("/auth/login", middelwares.ApiGuardMiddleware(), api.AuthLogin)
router.POST("/auth/logout", middelwares.ApiGuardMiddleware(), api.AuthLogout)
// Category Routers
router.GET("/category/list", middelwares.ApiGuardMiddleware(), api.CategoryList)
// Product Routers
router.GET("/product/list", middelwares.ApiGuardMiddleware(), api.ProductList)
router.POST("/product/detail/:id", middelwares.ApiGuardMiddleware(), api.ProductDetail)
// User Routers
router.POST("/user/update-profile", middelwares.ApiGuardMiddleware(), api.UserUpdateProfile)
// Order Routers
router.POST("/order/create", middelwares.ApiGuardMiddleware(), api.OrderCreate)
// Kafka Consumer
//helpers.KafkaConsumerWorker("General")
// Run the server
err := router.Run(":8080")
if err != nil {
return
}
}