in seata/gateway/server_c/server_c.go [33:87]
func main() {
r := gin.Default()
r.POST("/service-c/try", func(context *gin.Context) {
inv := &Inventory{}
err := context.BindJSON(inv)
if err == nil {
context.JSON(200, gin.H{
"success": true,
"message": fmt.Sprintf("inventory %d tried!", inv.ID),
})
return
}
context.JSON(400, gin.H{
"success": false,
"message": err.Error(),
})
})
r.POST("/service-c/confirm", func(context *gin.Context) {
inv := &Inventory{}
err := context.BindJSON(inv)
if err == nil {
fmt.Println(fmt.Sprintf("inventory %d confirmed!", inv.ID))
context.JSON(200, gin.H{
"success": true,
"message": fmt.Sprintf("inventory %d confirmed!", inv.ID),
})
return
}
context.JSON(400, gin.H{
"success": false,
"message": err.Error(),
})
})
r.POST("/service-c/cancel", func(context *gin.Context) {
inv := &Inventory{}
err := context.BindJSON(inv)
if err == nil {
fmt.Println(fmt.Sprintf("inventory %d canceled!", inv.ID))
context.JSON(200, gin.H{
"success": true,
"message": fmt.Sprintf("inventory %d canceled!", inv.ID),
})
return
}
context.JSON(400, gin.H{
"success": false,
"message": err.Error(),
})
})
r.Run(":8082")
}