From aedb1903f00ac828f2525996b6811dd22d436125 Mon Sep 17 00:00:00 2001 From: perp Date: Tue, 4 Jun 2024 16:31:43 +0100 Subject: [PATCH] Moved Error & Token into v1 models & fixed imports --- internal/context/context.go | 6 +++--- internal/models/{ => v1}/error.go | 4 ++-- internal/models/{ => v1}/token.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename internal/models/{ => v1}/error.go (79%) rename internal/models/{ => v1}/token.go (97%) diff --git a/internal/context/context.go b/internal/context/context.go index 6d17457..8aae65b 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -17,7 +17,7 @@ package context import ( "git.supernets.org/perp/gopay/internal/config" "git.supernets.org/perp/gopay/internal/database" - "git.supernets.org/perp/gopay/internal/models" + v1 "git.supernets.org/perp/gopay/internal/models/v1" "github.com/gin-gonic/gin" ) @@ -50,7 +50,7 @@ func (ctx *Context) Route(handler func(ctx *Context)) func(*gin.Context) { // Return an Error func (ctx *Context) Error(code int, err string) { - error := &models.Error{ + error := &v1.Error{ Type: err, } ctx.JSON(code, error) @@ -58,7 +58,7 @@ func (ctx *Context) Error(code int, err string) { // Return a Token func (ctx *Context) Token(token string) { - token_ := &models.Token{ + token_ := &v1.Token{ Token: token, } ctx.JSON(200, token_) diff --git a/internal/models/error.go b/internal/models/v1/error.go similarity index 79% rename from internal/models/error.go rename to internal/models/v1/error.go index 183b7a8..49da333 100644 --- a/internal/models/error.go +++ b/internal/models/v1/error.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package models +package v1 // Error response type Error struct { - Type string `json:"type"` + Type string `json:"type" enums:"DatabaseError,InternalServerError,InvalidPassword,InvalidUsername,MissingBody,RegistrationDisabled,UsernameTaken"` } diff --git a/internal/models/token.go b/internal/models/v1/token.go similarity index 97% rename from internal/models/token.go rename to internal/models/v1/token.go index 397760a..f4246e8 100644 --- a/internal/models/token.go +++ b/internal/models/v1/token.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package models +package v1 // Token response type Token struct {