constants

package
v0.0.0-...-0064678 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WriteWait      = 600 * time.Second
	PongWait       = 600 * time.Second
	PingPeriod     = PongWait * 9 / 10
	MaxMessageSize = 1024 * 1024 * 1024

	JoinChat    = "join"
	LeaveChat   = "leave"
	JoinedChat  = "joined"
	LeftChat    = "left"
	SendChat    = "send"
	SendFile    = "send_file"
	SendSticker = "send_sticker"
	ReadChat    = "read"
	Empty       = ""

	ErrChat           = "error"
	ErrChatDoNotExist = "room does not exit"
	ErrRequest        = "bad request"
)
View Source
const (
	ViperJWTTTLKey    = "service.jwt_ttl"
	ViperJWTSecretKey = "service.jwt_secret"

	ViperCSRFTTLKey    = "service.csrf_ttl"
	ViperCSRFSecretKey = "service.csrf_secret"

	ConfigAuthPost = "microservice_auth.port"
	ConfigAuthHost = "microservice_auth.host"
)
View Source
const (
	CommunityPost = "community"
	UserPost      = "user"
)
View Source
const (
	HeaderKeyUserID       = "User-Id"
	HeaderKeyRequestID    = "X-Request-Id"
	HeaderKeyUserAuthType = "User-Auth-Type"
)
View Source
const (
	CookieKeyAuthToken = "Auth-Token"
	CookieKeyCSRFToken = "X-CSRF-Token"
)
View Source
const (
	FrameRepresentativeCheckRegisterInitToken = "3"
)
View Source
const (
	QueryDelimiter = ","
)

Variables

View Source
var (
	// Unathorized
	ErrMissingAuthToken  = &CodedError{errors.New("missing authorization token"), http.StatusUnauthorized}
	ErrMissingAuthCookie = &CodedError{errors.New("missing authorization cookie"), http.StatusUnauthorized}

	ErrMissingCSRFCookie = &CodedError{errors.New("missing csrf cookie"), http.StatusUnauthorized}
	ErrCSRFTokenWrong    = &CodedError{errors.New("wrong csrf token in cookie"), http.StatusUnauthorized}

	ErrPasswordMismatch = &CodedError{errors.New("password mismatch"), http.StatusUnauthorized}

	ErrAuthTokenInvalid        = &CodedError{errors.New("authorization token is invalid"), http.StatusUnauthorized}
	ErrUnexpectedSigningMethod = &CodedError{errors.New("unexpected signing method"), http.StatusUnauthorized}

	ErrHashInvalid = &CodedError{errors.New("hash is invalid"), http.StatusUnauthorized}

	// Forbidden
	ErrAuthTokenExpired = &CodedError{errors.New("authorization token is expired"), http.StatusForbidden}
	ErrAuthorIDMismatch = &CodedError{errors.New("author id mismatch"), http.StatusForbidden}

	// Bad Request
	ErrBindRequest     = &CodedError{errors.New("failed to bind request"), http.StatusBadRequest}
	ErrValidateRequest = &CodedError{errors.New("failed to validate request"), http.StatusBadRequest}
	ErrDBNotFound      = &CodedError{errors.New("not found in the database"), http.StatusBadRequest}
	ErrBadJson         = &CodedError{errors.New("bad json request"), http.StatusBadRequest}
	ErrPassword        = &CodedError{errors.New("error generating hash"), http.StatusBadRequest}

	// Internal
	ErrSignToken      = &CodedError{errors.New("failed to sign token"), http.StatusInternalServerError}
	ErrGenerateUUID   = &CodedError{errors.New("failed to generate UUID"), http.StatusInternalServerError}
	ErrParseAuthToken = &CodedError{errors.New("failed to parse authorization token"), http.StatusInternalServerError}

	// Conflict
	ErrEmailAlreadyTaken = &CodedError{errors.New("email is taken already by other user"), http.StatusConflict}

	// Not Uniq
	ErrAddYourself         = &CodedError{errors.New("can't make yourself friend"), http.StatusConflict}
	ErrRequestAlreadyExist = &CodedError{errors.New("your request already was sent"), http.StatusConflict}
	ErrAlreadyFriends      = &CodedError{errors.New("your already friend with this person"), http.StatusConflict}
	ErrAlreadyFollower     = &CodedError{errors.New("you already in community"), http.StatusConflict}

	// Chat
	ErrSingleChat         = &CodedError{errors.New("you can't create dialog with no one"), http.StatusBadRequest}
	ErrDialogAlreadyExist = &CodedError{errors.New("dialog already exist"), http.StatusConflict}
)
View Source
var (
	ErrAuthConnection = errors.New("auth microservice connection error")
)
View Source
var Upgrader = websocket.Upgrader{
	ReadBufferSize:  4096,
	WriteBufferSize: 4096,
	CheckOrigin:     func(r *http.Request) bool { return true },
}

Functions

func GetAPIEntry

func GetAPIEntry() string

func GetServiceEntry

func GetServiceEntry() string

Types

type CodedError

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

CodedError is an error wrapper which wraps errors with http status codes.

func (*CodedError) Code

func (ce *CodedError) Code() int

func (*CodedError) Error

func (ce *CodedError) Error() string

type CtxKeyUserID

type CtxKeyUserID struct{}

CtxKeyUserID maps string.

type CtxKeyXRequestID

type CtxKeyXRequestID struct{}

CtxKeyXRequestID maps string.

Jump to

Keyboard shortcuts

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