Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New(MessageNotFound) ErrWrongPassword = errors.New(MessageWrongPassword) ErrAlreadyExists = errors.New(MessageAlreadyExists) ErrValidationFailed = errors.New(MessageValidationFailed) )
View Source
var ( MessageSuccess = "Success" MessageInternalError = "Internal server error" MessageFailedDecodeJSON = "Failed to decode JSON" )
View Source
var ( MessageNotFound = "User not found" MessageWrongPassword = "Wrong password" MessageAlreadyExists = "User already exists" MessageValidationFailed = "Validation failed" MessageMustAbove18 = "Age must above 18" )
View Source
var ( MinName = 3 MaxName = 50 MinUsername = 3 MaxUsername = 30 )
View Source
var SexList = []interface{}{Male, Female}
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) CreateUser ¶
func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request)
type Repository ¶
type Repository interface { Create(ctx context.Context, user *User) (err error) GetByUsername(ctx context.Context, username string) (user User, err error) }
func NewRepository ¶
func NewRepository(db *sql.DB) Repository
type Service ¶
type Service interface { Create(ctx context.Context, payload UserCreatePayload) (resp UserAuthentication, err error) Login(ctx context.Context, payload UserLoginPayload) (resp UserAuthentication, err error) }
func NewService ¶
func NewService(cfg config.AppConfig, repository Repository) Service
type User ¶
type User struct { ID uint64 `json:"-"` UID string `json:"uid"` Name string `json:"name"` Email string `json:"email"` Username string `json:"username"` HashedPassword *string `json:"-"` Sex Sex `json:"sex"` Birthdate time.Time `json:"birthdate"` Verified bool `json:"verified"` MaxSwipes int `json:"maxs_swipes"` CreatedAt time.Time `json:"created_at"` }
type UserAuthentication ¶
type UserAuthentication struct {
Token string `json:"token"`
}
type UserAuthenticationResponse ¶
type UserAuthenticationResponse struct { servicebase.ResponseBody Data *UserAuthentication `json:"data,omitempty"` }
type UserCreatePayload ¶
type UserCreatePayload struct { Name string `json:"name"` Email string `json:"email"` Username string `json:"username"` Password string `json:"password"` Sex Sex `json:"sex"` Birthdate string `json:"birthdate"` TimeLayout string `json:"-"` }
func (UserCreatePayload) NewLayoutDateOnly ¶
func (p UserCreatePayload) NewLayoutDateOnly() UserCreatePayload
func (UserCreatePayload) Validate ¶
func (p UserCreatePayload) Validate() error
type UserLoginPayload ¶
type UserLoginPayload struct { Username string `json:"username"` Password string `json:"password"` }
func (UserLoginPayload) Validate ¶
func (p UserLoginPayload) Validate() error
type UserResponse ¶
type UserResponse struct { servicebase.ResponseBody Data *User `json:"data,omitempty"` }
Click to show internal directories.
Click to hide internal directories.