Documentation ¶
Index ¶
- type AddUser
- type Handler
- func (h *Handler) Create() http.HandlerFunc
- func (h *Handler) Delete(s auth.Session) http.HandlerFunc
- func (h *Handler) Get() http.HandlerFunc
- func (h *Handler) GetByEmail() http.HandlerFunc
- func (h *Handler) GetByID() http.HandlerFunc
- func (h *Handler) GetByUsername() http.HandlerFunc
- func (h *Handler) Search() http.HandlerFunc
- func (h *Handler) Update() http.HandlerFunc
- type ListUser
- type Service
- type UpdateUser
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddUser ¶
type AddUser struct { ID string `json:"id,omitempty"` CartID string `json:"cart_id,omitempty" db:"cart_id"` Username string `json:"username,omitempty" validate:"required,max=25"` Email string `json:"email,omitempty" validate:"email,required"` Password string `json:"password,omitempty" validate:"required,min=6"` IsAdmin bool `json:"is_admin,omitempty" db:"is_admin"` CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` }
AddUser is used to create new users.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles user endpoints.
func NewHandler ¶
func NewHandler(dev bool, userS Service, cartS cart.Service, emailer email.Emailer, cache *memcache.Client) Handler
NewHandler returns a new user handler.
func (*Handler) Create ¶
func (h *Handler) Create() http.HandlerFunc
Create creates a new user and saves it.
func (*Handler) Delete ¶
func (h *Handler) Delete(s auth.Session) http.HandlerFunc
Delete removes a user.
func (*Handler) GetByEmail ¶
func (h *Handler) GetByEmail() http.HandlerFunc
GetByEmail lists the user with the id requested.
func (*Handler) GetByID ¶
func (h *Handler) GetByID() http.HandlerFunc
GetByID lists the user with the id requested.
func (*Handler) GetByUsername ¶
func (h *Handler) GetByUsername() http.HandlerFunc
GetByUsername lists the user with the id requested.
func (*Handler) Search ¶
func (h *Handler) Search() http.HandlerFunc
Search looks for the products with the given value.
func (*Handler) Update ¶
func (h *Handler) Update() http.HandlerFunc
Update updates the user with the given id.
type ListUser ¶
type ListUser struct { ID string `json:"id,omitempty"` CartID string `json:"cart_id,omitempty" db:"cart_id"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty" validate:"email"` IsAdmin bool `json:"is_admin,omitempty" db:"is_admin"` Reviews []review.Review `json:"reviews,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt zero.Time `json:"updated_at,omitempty" db:"updated_at"` }
ListUser is the structure used to list users.
type Service ¶
type Service interface { Create(ctx context.Context, user AddUser) error Delete(ctx context.Context, id string) error Get(ctx context.Context, params params.Query) ([]ListUser, error) GetByEmail(ctx context.Context, email string) (ListUser, error) GetByID(ctx context.Context, id string) (ListUser, error) GetByUsername(ctx context.Context, username string) (ListUser, error) IsAdmin(ctx context.Context, id string) (bool, error) Search(ctx context.Context, query string) ([]ListUser, error) Update(ctx context.Context, u UpdateUser, id string) error }
Service provides user operations.
type UpdateUser ¶
type UpdateUser struct {
Username string `json:"username,omitempty" validate:"required"`
}
UpdateUser is the structure used to update users.
type User ¶
type User struct { ID string `json:"id,omitempty" validate:"uuid4_rfc4122"` CartID string `json:"cart_id,omitempty" db:"cart_id"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty" validate:"email"` Password string `json:"password,omitempty"` VerifiedEmail bool `json:"verified_email,omitempty" db:"verified_email"` IsAdmin bool `json:"is_admin,omitempty" db:"is_admin"` ConfirmationCode string `json:"confirmation_code,omitempty" db:"confirmation_code"` Orders []ordering.Order `json:"orders,omitempty"` Reviews []review.Review `json:"reviews,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt zero.Time `json:"updated_at,omitempty" db:"updated_at"` }
User represents platform customers. Each user has a unique cart.
Click to show internal directories.
Click to hide internal directories.