Documentation ¶
Index ¶
Constants ¶
const ( SessionIdKey = "session_id" PathToAvatars = "assets" )
const (
StatusOK = "OK"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserHandler ¶
type UserHandler struct { UserUseCase user_domain.UserUseCase S3Handler *s3.Handler }
func MakeHandler ¶
func MakeHandler(userUseCase user_domain.UserUseCase, s3Handler *s3.Handler) UserHandler
func (*UserHandler) GetSelfUser ¶
func (a *UserHandler) GetSelfUser(c echo.Context) error
GetSelfUser godoc @Summary Get @Description getting user by session_id (in cookie) @Tags user @Accept application/json @Produce application/json @Param X-CSRF-TOKEN header string true "csrf-token" @Param Cookie header string true "the same csrf-token by key X-CSRF-TOKEN and auth-token by key session_id" @Success 200 {object} domain.User @Failure 401 {object} webUtils.Error "User unauthorized" @Router /api/v1/users/self [get]
func (*UserHandler) GetUser ¶
func (a *UserHandler) GetUser(c echo.Context) error
GetUser godoc @Summary Get @Description getting user by id @Tags user @Accept application/json @Produce application/json @Param id path integer true "id of user which need to be getted" @Success 200 {object} domain.User @Failure 400 {object} webUtils.Error "Data is invalid" @Failure 404 {object} webUtils.Error "User not found" @Failure 405 {object} webUtils.Error "Method is not allowed" @Router /api/v1/users/{id} [get]
func (*UserHandler) UpdateSelfUser ¶
func (a *UserHandler) UpdateSelfUser(c echo.Context) error
UpdateSelfUser godoc @Summary Update @Description updating user by session_id @Tags user @Accept application/json @Produce application/json @Param User body domain.User true "a non-zero field means that it needs to be changed" @Param X-CSRF-TOKEN header string true "csrf-token" @Param Cookie header string true "the same csrf-token by key X-CSRF-TOKEN and auth-token by key session_id" @Success 200 {object} webUtils.Success @Failure 400 {object} webUtils.Error "invalid field values" @Failure 401 {object} webUtils.Error "user unauthorized" @Failure 422 {object} webUtils.Error "invalid json" @Router /api/v1/users/self [patch]
func (*UserHandler) UploadAvatar ¶
func (a *UserHandler) UploadAvatar(c echo.Context) error
UploadAvatar godoc @Summary Update @Description updating user avatar @Tags user @Accept application/json @Produce application/json @Param X-CSRF-Token header string true "csrf-token" @Param Cookie header string true "cookie" @Param avatar formData file true "avatar file" @Success 200 {object} webUtils.Success @Failure 400 {object} webUtils.Error "invalid field values" @Router /api/v1/users/upload_avatar [patch]
type UserResponse ¶
type UserResponseProto ¶
type UserResponseProto struct { Status string `json:"status"` Error string `json:"error,omitempty"` Result *user_microservice_domain.User `json:"result,omitempty"` }