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 ( ParseError = map[string]*CodedError{ ErrMissingAuthToken.Error(): ErrMissingAuthToken, ErrMissingAuthCookie.Error(): ErrMissingAuthCookie, ErrMissingCSRFCookie.Error(): ErrMissingCSRFCookie, ErrCSRFTokenWrong.Error(): ErrCSRFTokenWrong, ErrPasswordMismatch.Error(): ErrPasswordMismatch, ErrAuthTokenInvalid.Error(): ErrAuthTokenInvalid, ErrUnexpectedSigningMethod.Error(): ErrUnexpectedSigningMethod, ErrAuthTokenExpired.Error(): ErrAuthTokenExpired, ErrAuthorIDMismatch.Error(): ErrAuthorIDMismatch, ErrBindRequest.Error(): ErrBindRequest, ErrValidateRequest.Error(): ErrValidateRequest, ErrDBNotFound.Error(): ErrDBNotFound, ErrBadJson.Error(): ErrBadJson, ErrPassword.Error(): ErrPassword, ErrSignToken.Error(): ErrSignToken, ErrGenerateUUID.Error(): ErrGenerateUUID, ErrParseAuthToken.Error(): ErrParseAuthToken, ErrEmailAlreadyTaken.Error(): ErrEmailAlreadyTaken, ErrAddYourself.Error(): ErrAddYourself, ErrRequestAlreadyExist.Error(): ErrRequestAlreadyExist, ErrAlreadyFriends.Error(): ErrAlreadyFriends, ErrAlreadyFollower.Error(): ErrAlreadyFollower, ErrSingleChat.Error(): ErrSingleChat, ErrDialogAlreadyExist.Error(): ErrDialogAlreadyExist, } )
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
Click to show internal directories.
Click to hide internal directories.