Documentation ¶
Overview ¶
Users routes and controllers logic package for the backend.
Index ¶
- func NewUserRepository(cache db.Cacher) models.UserRepositoryInterface
- func NewUserRouter(userController *UserController) chi.Router
- func NewUserService(postRepository models.PostRepositoryInterface, ...) models.UserServiceInterface
- type UserController
- func (c *UserController) Activate(w http.ResponseWriter, r *http.Request)
- func (c *UserController) Create(w http.ResponseWriter, r *http.Request)
- func (c *UserController) Delete(w http.ResponseWriter, r *http.Request)
- func (c *UserController) GetAll(w http.ResponseWriter, r *http.Request)
- func (c *UserController) GetByID(w http.ResponseWriter, r *http.Request)
- func (c *UserController) GetPosts(w http.ResponseWriter, r *http.Request)
- func (c *UserController) PassphraseResetRequest(w http.ResponseWriter, r *http.Request)
- func (c *UserController) ResetPassphrase(w http.ResponseWriter, r *http.Request)
- func (c *UserController) Update(w http.ResponseWriter, r *http.Request)
- func (c *UserController) UploadAvatar(w http.ResponseWriter, r *http.Request)
- type UserRepository
- func (r *UserRepository) Delete(userID string) error
- func (r *UserRepository) GetAll() (*map[string]models.User, error)
- func (r *UserRepository) GetByID(userID string) (*models.User, error)
- func (r *UserRepository) GetPage(pageOpts interface{}) (*map[string]models.User, error)
- func (r *UserRepository) Save(user *models.User) error
- type UserService
- func (s *UserService) Create(ctx context.Context, user *models.User) error
- func (s *UserService) Delete(ctx context.Context, userID string) error
- func (s *UserService) FindAll(ctx context.Context) (*map[string]models.User, error)
- func (s *UserService) FindByID(ctx context.Context, userID string) (*models.User, error)
- func (s *UserService) Update(ctx context.Context, userRequest interface{}) error
- type UserUpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewUserRepository ¶ added in v0.44.22
func NewUserRepository(cache db.Cacher) models.UserRepositoryInterface
func NewUserRouter ¶ added in v0.44.23
func NewUserRouter(userController *UserController) chi.Router
func NewUserService ¶ added in v0.44.23
func NewUserService( postRepository models.PostRepositoryInterface, userRepository models.UserRepositoryInterface, tokenRepository models.TokenRepositoryInterface, ) models.UserServiceInterface
Types ¶
type UserController ¶ added in v0.44.23
type UserController struct {
// contains filtered or unexported fields
}
func NewUserController ¶ added in v0.44.23
func NewUserController(userService models.UserServiceInterface) *UserController
func (*UserController) Activate ¶ added in v0.44.23
func (c *UserController) Activate(w http.ResponseWriter, r *http.Request)
func (*UserController) Create ¶ added in v0.44.23
func (c *UserController) Create(w http.ResponseWriter, r *http.Request)
Create is the users handler that processes input and creates a new user.
@Summary Add new user @Description add new user @Tags users @Accept json @Produce json @Param request body models.User true "new user's request body" @Success 200 {object} common.APIResponse @Failure 400 {object} common.APIResponse @Failure 403 {object} common.APIResponse @Failure 409 {object} common.APIResponse @Failure 500 {object} common.APIResponse @Router /users [post]
func (*UserController) Delete ¶ added in v0.44.23
func (c *UserController) Delete(w http.ResponseWriter, r *http.Request)
func (*UserController) GetAll ¶ added in v0.44.23
func (c *UserController) GetAll(w http.ResponseWriter, r *http.Request)
func (*UserController) GetByID ¶ added in v0.44.23
func (c *UserController) GetByID(w http.ResponseWriter, r *http.Request)
func (*UserController) GetPosts ¶ added in v0.44.23
func (c *UserController) GetPosts(w http.ResponseWriter, r *http.Request)
func (*UserController) PassphraseResetRequest ¶ added in v0.44.23
func (c *UserController) PassphraseResetRequest(w http.ResponseWriter, r *http.Request)
func (*UserController) ResetPassphrase ¶ added in v0.44.23
func (c *UserController) ResetPassphrase(w http.ResponseWriter, r *http.Request)
func (*UserController) Update ¶ added in v0.44.23
func (c *UserController) Update(w http.ResponseWriter, r *http.Request)
Update is the users handler that allows the user to change their lists/options/passphrase.
@Summary Update user's data @Description update user's data @Tags users @Produce json @Param request body users.UserUpdateRequest true "data to update" @Param userID path string true "ID of the user to update" @Success 200 {object} common.APIResponse @Failure 400 {object} common.APIResponse @Failure 403 {object} common.APIResponse @Failure 404 {object} common.APIResponse @Failure 409 {object} common.APIResponse @Failure 500 {object} common.APIResponse @Router /users/{userID}/{updateType} [patch]
func (*UserController) UploadAvatar ¶ added in v0.44.23
func (c *UserController) UploadAvatar(w http.ResponseWriter, r *http.Request)
type UserRepository ¶ added in v0.44.22
type UserRepository struct {
// contains filtered or unexported fields
}
The implementation of pkg/models.UserRepositoryInterface.
func (*UserRepository) Delete ¶ added in v0.44.22
func (r *UserRepository) Delete(userID string) error
func (*UserRepository) GetAll ¶ added in v0.44.22
func (r *UserRepository) GetAll() (*map[string]models.User, error)
func (*UserRepository) GetByID ¶ added in v0.44.22
func (r *UserRepository) GetByID(userID string) (*models.User, error)
type UserService ¶ added in v0.44.23
type UserService struct {
// contains filtered or unexported fields
}
func (*UserService) Delete ¶ added in v0.44.23
func (s *UserService) Delete(ctx context.Context, userID string) error