delivery

package
v0.0.0-...-3122bcc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUnauthorized = 401

	ResponseSuccessfulSignUp = "Successful sign up"
	ResponseSuccessfulSignIn = "Successful sign in"
	ResponseSuccessfulLogOut = "Successful log out"

	ErrUnauthorized = "Вы не авторизованны"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(sessionManagerClient auth.SessionMangerClient) (*AuthHandler, error)

func (*AuthHandler) LogOutHandler

func (a *AuthHandler) LogOutHandler(w http.ResponseWriter, r *http.Request)

LogOutHandler godoc

@Summary    logout
@Description  logout in app
@Tags auth
@Produce    json
@Success    200  {object} responses.ResponseSuccessful
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Error".
@Router      /logout [post]

func (*AuthHandler) SignInHandler

func (a *AuthHandler) SignInHandler(w http.ResponseWriter, r *http.Request)

SignInHandler godoc

@Summary    signin
@Description  signin in app
@Tags auth
@Produce    json
@Param      email  query string true  "user email for signin"
@Param      password  query string true  "user password for signin"
@Success    200  {object} responses.ResponseSuccessful
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Error". Внутри body статус может быть badContent(4400), badFormat(4000)//nolint:lll
@Router      /signin [get]

func (*AuthHandler) SignUpHandler

func (a *AuthHandler) SignUpHandler(w http.ResponseWriter, r *http.Request)

SignUpHandler godoc

@Summary    signup
@Description  signup in app

@Tags auth

@Accept      json
@Produce    json
@Param      preUser  body models.UserWithoutID true  "user data for signup"
@Success    200  {object} responses.ResponseSuccessful
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Error". Внутри body статус может быть badContent(4400), badFormat(4000)//nolint:lll
@Router      /signup [post]

type IUserService

type IUserService interface {
	GetUserWithoutPasswordByID(ctx context.Context, userID uint64) (*models.UserWithoutPassword, error)
	UpdateUser(ctx context.Context, r io.Reader, isPartialUpdate bool, userID uint64) (*models.UserWithoutPassword, error)
}

type ProfileHandler

type ProfileHandler struct {
	// contains filtered or unexported fields
}

func NewProfileHandler

func NewProfileHandler(userService IUserService,
	sessionManagerClient auth.SessionMangerClient,
) (*ProfileHandler, error)

func (*ProfileHandler) GetUserHandler

func (u *ProfileHandler) GetUserHandler(w http.ResponseWriter, r *http.Request)
GetUserHandler godoc

@Summary get profile @Description get profile by id

@Tags profile

@Produce    json
@Param      id  query uint64 true  "user id"
@Success    200  {object} ProfileResponse
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Error" Внутри body статус может быть badFormat(4000)
@Router      /profile/get [get]

func (*ProfileHandler) PartiallyUpdateUserHandler

func (u *ProfileHandler) PartiallyUpdateUserHandler(w http.ResponseWriter, r *http.Request)

PartiallyUpdateUserHandler godoc

@Summary    update profile
@Description  update some fields of profile

@Tags profile

@Accept      json
@Produce    json
@Param      user  body models.UserWithoutPassword false  "полностью опционален"
@Success    200  {object} ProfileResponse
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Error". Внутри body статус может быть badContent(4400), badFormat(4000)
@Router      /profile/update [patch]
@Router      /profile/update [put]

type ProfileResponse

type ProfileResponse struct {
	Status int                         `json:"status"`
	Body   *models.UserWithoutPassword `json:"body"`
}

func NewProfileResponse

func NewProfileResponse(body *models.UserWithoutPassword) *ProfileResponse

func (ProfileResponse) MarshalEasyJSON

func (v ProfileResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ProfileResponse) MarshalJSON

func (v ProfileResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ProfileResponse) UnmarshalEasyJSON

func (v *ProfileResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ProfileResponse) UnmarshalJSON

func (v *ProfileResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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