gopay/internal/router/api/v1/account/delete.go

32 lines
576 B
Go
Raw Normal View History

2024-06-06 19:08:04 +00:00
package account
import (
"git.supernets.org/perp/gopay/internal/context"
)
// @summary Delete an account
// @tags account
// @accept json
// @produce json
// @success 204
// @response default {object} v1.Error "There was an error"
// @router /v1/account/delete [delete]
func Delete(ctx *context.Context) {
// Call middleware
ctx.GetAccount()
// Account not found
if ctx.Account == nil {
return
}
// Delete account
err := ctx.Database.Account.DeleteByID(ctx.Account.ID)
if err != nil {
ctx.Error(500, "InternalServerError")
return
}
ctx.String(200, "")
}