Move json struct in a new module
This commit is contained in:
@@ -2,18 +2,14 @@ package routes
|
||||
|
||||
import (
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/appcontext"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/dto"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/model"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/myvalidator"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
type userSignup struct {
|
||||
Username string `json:"username" binding:"required,min=2,max=20"`
|
||||
Password string `json:"password" binding:"required,min=6,max=100"`
|
||||
}
|
||||
|
||||
func PostSignupHandler(ac appcontext.AppContext) {
|
||||
var user userSignup
|
||||
var user dto.UserSignup
|
||||
err := ac.C.ShouldBindJSON(&user)
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
@@ -32,7 +28,7 @@ func PostSignupHandler(ac appcontext.AppContext) {
|
||||
ac.C.String(200, "Success")
|
||||
}
|
||||
|
||||
func userWsToDb(u userSignup) (model.User, error) {
|
||||
func userWsToDb(u dto.UserSignup) (model.User, error) {
|
||||
user := model.User{
|
||||
Name: u.Username,
|
||||
Password: "",
|
||||
|
||||
Reference in New Issue
Block a user