base

package
v0.0.0-...-79bd89f Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package base provides some base functions such as random code and valid phoneNumber check

Index

Constants

View Source
const (
	JwtKey          = "36861f1530941263e6f61b43743074d8"
	TokenSalt       = "03e23aeb89f13ff4323e641a559db414"
	PrivateChatSalt = "e1b46b79232e42eb4656ee2c810a1d5b"
	UserIdSalt      = "1d143777c383ec8f7c7b7e2a4879ce85"
	TodoIdSalt      = "f7f32e72f01973acc96e5038113f67e4"
	ProjectIdSalt   = "d27023a4f4939d8059b5eed20e86e6be"
	MissionIdSalt   = "d27023a4f4939d8059b5eed20e86e6be"
	CommentIdSalt   = "d27023a4f4939d8059b5eed20e86e6be"
	ChatIdSalt      = "d27023a4f4939d8059b5eed20e86e6be"
)
View Source
const (
	AvatarPath = "static/avatar/"
)

Variables

View Source
var (
	Domain    string
	Bucket    string
	AccessKey string
	SecretKey string
)
View Source
var QiNiuExpire uint32 = 3600

Functions

func BadReqErr

func BadReqErr(w http.ResponseWriter, desc string)

BadReqErr means 400 bad request error

func EncryptedPassword

func EncryptedPassword(pwd string) string

EncryptedPassword encrypts user's password High level secret,use "scrypt" instead of hash+salt

func ForbidErr

func ForbidErr(w http.ResponseWriter, desc string)

ForbidErr means 403 forbidden error

func GenerateAvatar

func GenerateAvatar(phone string) (string, error)

GenerateAvatar saves avatar file and return relative path

func HashedChatId

func HashedChatId(id int) string

HashedChatId hashed with comment salt

func HashedCommentId

func HashedCommentId(id int) string

HashedCommentId hashed with comment salt

func HashedMissionId

func HashedMissionId(id int) string

HashedMissionId hashed with mission salt

func HashedProjectId

func HashedProjectId(id int) string

HashedProjectId hashed with project salt

func HashedTodoId

func HashedTodoId(id int) string

HashedTodoId hashed with to-do salt

func HashedUserId

func HashedUserId(id int) string

HashedUserId hashed with user salt

func InIntSlice

func InIntSlice(a int, list []int) bool

InIntSlice checks if an int is in the slice []int

func InternalErr

func InternalErr(w http.ResponseWriter, desc string)

InternalErr means 500 internal error

func MakeToken

func MakeToken(id int) string

MakeToken makes jwt token with auth id Add "Bearer " additionally

func MethodNAErr

func MethodNAErr(w http.ResponseWriter, desc string)

MethodNAErr means 405 method not allowed error

func NewPrivateChatId

func NewPrivateChatId(raw string) string

NewPrivateChatId hashed with chat salt

func NotFoundErr

func NotFoundErr(w http.ResponseWriter, desc string)

NotFoundErr means 404 not found error

func ParseToken

func ParseToken(ah string) (uid int, err error)

ParseToken parses auth id from token Compatible with token starts with "Bearer "

func QiNiuDownloadUrl

func QiNiuDownloadUrl(key string) string

QiNiuDownloadUrl return download url for file key

func QiNiuUploadToken

func QiNiuUploadToken() string

QiNiuUploadToken return token for upload pics

func RandomCodeSix

func RandomCodeSix() string

RandomCodeSix generates random 6-length code

func UnAuthErr

func UnAuthErr(w http.ResponseWriter, desc string)

UnAuthErr means 401 unauthorized error

func ValidMail

func ValidMail(mail string) bool

ValidMail checks if the mail format is legal

func ValidPhone

func ValidPhone(phone string) bool

ValidPhone checks if the phone number is legal

func ValidSamId

func ValidSamId(samId string) bool

ValidSamId checks if the sam id is legal

Types

This section is empty.

Jump to

Keyboard shortcuts

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