fix: change API design to be more RESTful

This commit is contained in:
Muyao CHEN
2024-10-07 23:25:25 +02:00
parent c1173b4bcc
commit cb7a4bf5c5
4 changed files with 142 additions and 18 deletions

View File

@ -36,10 +36,8 @@ import (
// User is the user controller interface, it describes all the handlers
// that need to be implemented for the /user endpoint
type User interface {
Signup(core.Context)
Create(core.Context)
UpdateInfo(*gin.Context)
Login(*gin.Context)
Logout(*gin.Context)
ChangePassword(*gin.Context)
}
@ -59,7 +57,7 @@ func NewUserController(us usecase.User) User {
}
}
func (uc *UserController) Signup(ctx core.Context) {
func (uc *UserController) Create(ctx core.Context) {
var params model.User
if err := ctx.Bind(&params); err != nil {
@ -87,11 +85,5 @@ func (uc *UserController) Signup(ctx core.Context) {
func (uc *UserController) UpdateInfo(ctx *gin.Context) {
}
func (uc *UserController) Login(ctx *gin.Context) {
}
func (uc *UserController) Logout(ctx *gin.Context) {
}
func (uc *UserController) ChangePassword(ctx *gin.Context) {
}

View File

@ -52,7 +52,7 @@ func Routes(engine *gin.Engine, c controller.AppController) *gin.Engine {
{
userV1 := v1.Group("/user")
{
userV1.POST("/signup", func(ctx *gin.Context) { c.User.Signup(ctx) })
userV1.POST("/create", func(ctx *gin.Context) { c.User.Create(ctx) })
}
}