-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.go
34 lines (27 loc) · 857 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
package main
import (
"log"
"net/http"
"github.com/boantp/go-mysql-rest-api/controllers"
"github.com/julienschmidt/httprouter"
)
func main() {
router := httprouter.New()
// Get Controller instance
tc := controllers.NewTaxCodeController()
cc := controllers.NewCartController()
oc := controllers.NewOrderController()
web := controllers.NewWebController()
/** REST API **/
// Get a tax code resource
router.GET("/tax_code", tc.GetTaxCode)
//POST object tax into cart or order_details
router.POST("/cart", cc.CreateCart)
//GET my bill with tax calculation result from order_details
router.GET("/order/:store_id", oc.GetMyBill)
/** Web Frontend **/
router.GET("/", web.Index)
router.POST("/front/cart/process", web.FrontCartProcess)
router.GET("/order_view/:store_id", web.ViewBill)
log.Fatal(http.ListenAndServe(":3000", router))
}