types

package
v0.0.0-...-3773cab Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// COMMON
	NOT_FOUND = 1001
	// USER 10xx
	EMAIL_ALREADY_REGISTER = 1002
	// COMMUNITY 11xx
	COMMUNITY_ALREADY_EXIST = 1102

	BAD_REQUEST              = 2000
	BAD_REQUEST_DATE_FORMAT  = 2001
	BAD_REQUEST_EMAIL_FORMAT = 2002
	WRONG_PASSWORD           = 2003
	WRONG_EMAIL              = 2004
	UNAUTHORIZED             = 2005

	INTERNAL_SERVER = 3000
)

RESPONSE CODEs 100x success 200x bad request | client side 300x error | server side

Variables

View Source
var (
	ErrUnAuth = errors.New("Unauthorized")
	// Error client side
	ErrRequestBadFormat     = errors.New("Incorrect Request Format")
	ErrDateOfBirthBadFormat = errors.New("Date of birth bad format: yyyy-mm-dd")
	ErrDecodeRequest        = errors.New("Decode failed")

	// Error server side
	// DB error
	ErrDBNotFound = errors.New("Records Not Found")
	// Server error || Common
	ErrServerInternal = errors.New("Internal server error")
	ErrValidator      = errors.New("Failed to validate request")
	// User
	ErrEmailAlreadyExist  = errors.New("Email already registered")
	ErrFailedCheckEmail   = errors.New("Failed checking email")
	ErrFailedCheckPass    = errors.New("Failed checking password")
	ErrFailedAuthenticate = errors.New("Failed to authenticate")
	// Community
	ErrFailedCheckCommName = errors.New("Failed checking community name")
	ErrCommAlreadyExist    = errors.New("Community already exist")
)

Functions

func HandleResponseError

func HandleResponseError(w http.ResponseWriter, er error)

Types

type Gender

type Gender int

type ResponseError

type ResponseError struct {
	Cod uint   `json:"code"`
	Err error  `json:"error"`
	Msg string `json:"message"`
}

func (*ResponseError) Code

func (r *ResponseError) Code() uint

func (*ResponseError) Error

func (r *ResponseError) Error() string

func (*ResponseError) Message

func (r *ResponseError) Message() string

type UserInfo

type UserInfo struct {
	UserId string `json:"user_id,omitempty"`
	Email  string `json:"email,omitempty"`

	FirstName   string     `json:"first_name,omitempty"`
	LastName    string     `json:"last_name,omitempty"`
	Gender      Gender     `json:"gender,omitempty"`
	DateOfBirth *time.Time `json:"date_of_birth,omitempty"`
	Roles       []string   `json:"roles,omitempty"`

	NickName string `json:"nick_name,omitempty"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (*UserInfo) ToClaims

func (ai *UserInfo) ToClaims(lifeTime time.Duration) *jwt.Claims

Jump to

Keyboard shortcuts

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