fix
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"git.trj.tw/golang/go-gallery/modules/context"
|
||||
)
|
||||
|
||||
// UserLogin route
|
||||
func UserLogin(c *context.Context) {
|
||||
loginArg := struct {
|
||||
Account string `form:"account" json:"account" binding:"required"`
|
||||
Password string `form:"password" json:"password" binding:"required"`
|
||||
}{
|
||||
Account: "",
|
||||
Password: "",
|
||||
}
|
||||
err := c.ShouldBind(&loginArg)
|
||||
if err != nil {
|
||||
c.NotFound("body not found")
|
||||
return
|
||||
}
|
||||
|
||||
c.Success("api success")
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.trj.tw/golang/go-gallery/models"
|
||||
"git.trj.tw/golang/go-gallery/modules/context"
|
||||
"git.trj.tw/golang/go-gallery/routers/account"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// NewServ - get new service
|
||||
func NewServ() *gin.Engine {
|
||||
r := gin.Default()
|
||||
r := gin.New()
|
||||
r.Use(gin.Logger())
|
||||
r.Use(gin.Recovery())
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -23,7 +25,6 @@ func SetDefaultRoutes(r *gin.Engine) {
|
||||
})
|
||||
return
|
||||
}
|
||||
fmt.Println(accs)
|
||||
c.JSON(200, accs)
|
||||
})
|
||||
|
||||
@@ -35,11 +36,9 @@ func SetDefaultRoutes(r *gin.Engine) {
|
||||
"message": "Success",
|
||||
})
|
||||
})
|
||||
api.GET("s/", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"status": 200,
|
||||
"message": "api sssss",
|
||||
})
|
||||
})
|
||||
}
|
||||
accountAPI := api.Group("/account")
|
||||
{
|
||||
accountAPI.POST("/login", context.PatchContext(account.UserLogin))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user