Documentation ¶
Index ¶
- type AppLoginUser
- type AppNewUser
- type AppUser
- type UserHandler
- func (h *UserHandler) GetByID(ctx context.Context, w http.ResponseWriter, _ *http.Request) error
- func (h *UserHandler) List(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *UserHandler) Login(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *UserHandler) Register(ctx context.Context, w http.ResponseWriter, r *http.Request) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppLoginUser ¶
type AppLoginUser struct { Username string `json:"username" validate:"required"` Password string `json:"password" validate:"required,len=8"` }
AppLoginUser what we require from user to login.
func (AppLoginUser) Validate ¶
func (app AppLoginUser) Validate() error
Validate checks the data in the model is considered clean.
type AppNewUser ¶
type AppNewUser struct { Name string `json:"username" validate:"required,min=3,max=64"` Password string `json:"password" validate:"required,min=8,max=256"` Roles []string `json:"roles" validate:"required,dive,oneof=USER ADMIN"` }
AppNewUser what we require from user to add new user.
func (AppNewUser) Validate ¶
func (app AppNewUser) Validate() error
Validate checks the data in the model is considered clean.
type AppUser ¶
type AppUser struct { ID string `json:"id"` Name string `json:"name"` PasswordHash []byte `json:"-"` Roles []string `json:"roles"` DateCreated string `json:"date_created"` }
AppUser represents application user.
type UserHandler ¶
func (*UserHandler) GetByID ¶
func (h *UserHandler) GetByID(ctx context.Context, w http.ResponseWriter, _ *http.Request) error
GetByID returns a user bu its ID.
func (*UserHandler) List ¶
func (h *UserHandler) List(ctx context.Context, w http.ResponseWriter, r *http.Request) error
List returns a list of users.
func (*UserHandler) Login ¶
func (h *UserHandler) Login(ctx context.Context, w http.ResponseWriter, r *http.Request) error
Login logins to the app with given credentials and returns JWT token.
func (*UserHandler) Register ¶
func (h *UserHandler) Register(ctx context.Context, w http.ResponseWriter, r *http.Request) error
Register adds new user to the app.
Click to show internal directories.
Click to hide internal directories.