userHttp

package
v0.0.0-...-704a905 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionIdKey  = "session_id"
	PathToAvatars = "assets"
)
View Source
const (
	StatusOK = "OK"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UserAvatarUploadResponse

type UserAvatarUploadResponse struct {
	Status string `json:"status"`
	Result string `json:"result,omitempty"`
}

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 UserResponse struct {
	Status string       `json:"status"`
	Error  string       `json:"error,omitempty"`
	Result *domain.User `json:"result,omitempty"`
}

type UserResponseProto

type UserResponseProto struct {
	Status string                         `json:"status"`
	Error  string                         `json:"error,omitempty"`
	Result *user_microservice_domain.User `json:"result,omitempty"`
}

type UserUpdateResponse

type UserUpdateResponse struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
	Result string `json:"result,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL