Documentation
¶
Index ¶
- Constants
- Variables
- func EncryptPassword(password string) string
- func GetErrHttpStatus(errCode int) int
- func GetErrMsg(errCode int) string
- func InitCache()
- func InitGlobal()
- func IsEmail(email string) bool
- func IsFileExists(filePath string) (bool, error)
- func M(collection string, f func(*mgo.Collection))
- func Session() *mgo.Session
- type Config
- type DBLogger
Constants ¶
View Source
const ( DOMAIN = "https://mmsystem.com" DOMAIN_API = "https://api.mmsystem.com" VERSION = "0.0.1" AUTH_REALM = "mmsystem.com" AUTH_TOKEN_NS = "auth:" //认证token存取前缀 CACHE_REDIS = "redis" CACHE_MEMORY = "memory" RUN_MODE_DEV = "dev" RUN_MODE_PRODUCT = "prod" LOG_ENGINE_FILE = "file" LOG_ENGINE_MONGODB = "mongodb" THUMB_FOLDER_NUM = 1024 THUMB_FORMAT = ".png" LOCAL_TIME_ZONE_OFFSET = 8 * 60 * 60 //Beijing(UTC+8:00) DEFAULT_FILE_MODE = 0755 USER = "user" )
View Source
const ( LOG_TYPE_DEFAULT = iota LOG_TYPE_REGISTER LOG_TYPE_ACTIVATION LOG_TYPE_LOGIN )
todo log type
View Source
const ( SUCCESS = 200 //Common ERR_DB_FAILED = 10001 ERR_EMAIL_NOT_AVAILABLE = 10002 ERR_UPLOAD_FAILED = 10003 ERR_DATA_INVALID = 10004 ERR_NO_PERMISSIONS = 10005 ERR_UNAUTHORIZED = 10006 ERR_RESOURCE_NOT_FOUND = 10007 ERR_RPC_FAILED = 10008 ERR_THUMB_FAILED = 10009 ERR_REDIS_NOT_AVAILABLE = 10010 ERR_PERMISSION_DENIED = 10011 //Register ERR_REG_EMAIL_EXISTS = 20001 ERR_REG_EMAIL_INVALID = 20002 ERR_REG_PASSWORD_INVALID = 20003 //login ERR_USER_NOT_EXISTS = 20101 ERR_PASSWORD_INVALID = 20102 ERR_USER_NOT_VERIFIED = 20103 ERR_LOGIN_FAILED = 20104 ERR_LOGOUT_FAILED = 20105 //reset ERR_FORGET_FAILED = 20301 ERR_RESET_INVALID = 20302 ERR_RESET_FAILED = 20303 )
Variables ¶
View Source
var ( Redis *redis.Client Cache *cache.Cache )
View Source
var ( Conf *Config ServiceControl string )
View Source
var ( DB *mgo.Database MongoSession *mgo.Session )
View Source
var (
TempDir string
)
Functions ¶
func EncryptPassword ¶
func GetErrHttpStatus ¶
func InitGlobal ¶
func InitGlobal()
func M ¶
func M(collection string, f func(*mgo.Collection))
Types ¶
type Config ¶
type Config struct {
//base
Mode string `goconf:"base:mode"`
Pidfile string `goconf:"base:pidfile"`
MaxProc int `goconf:"base:maxproc"`
HTTPBind string `goconf:"base:http.bind"`
HTTPReadTimeout time.Duration `goconf:"base:http.read.timeout:time"`
HTTPWriteTimeout time.Duration `goconf:"base:http.write.timeout:time"`
XSendFile bool `goconf:"base:http.sendfile"`
Cache string `goconf:"base:cache"`
//Storage string `goconf:"base.storage"`
StoragePath string `goconf:"base:storage.path"`
StorageThumbPath string `goconf:"base:storage.thumb.path"`
TokenDuration time.Duration `goconf:"base:token.duration:time"`
//db
DBUrl string `goconf:"db:db.url"`
DBName string `goconf:"db:db.name"`
DBTimeout time.Duration `goconf:"db:db.timeout:time"`
//redis
RedisUrl string `goconf:"redis:redis.url"`
RedisPassword string `goconf:"redis:redis.password"`
//rpc
RPCProtocol string `goconf:"rpc:protocol"`
RPCAddress string `goconf:"rpc:address"`
RPCPoolMaxTotal int `goconf:"rpc:pool.maxTotal"`
RPCPoolMaxIdle int `goconf:"rpc:pool.maxIdle"`
RPCPoolMinIdle int `goconf:"rpc:pool.minIdle"`
RPCPoolIdleTimeout time.Duration `goconf:"rpc:pool.idleTimeout:time"`
//log
LogEngine string `goconf:"log:engine"`
LogFilePath string `goconf:"log:file.path"`
LogFilePrefix string `goconf:"log:file.prefix"`
LogMongodbUrl string `goconf:"log:mongodb.url"`
LogMongodbDB string `goconf:"log:mongodb.db"`
//root user
RootEmail string `goconf:"root:email"`
RootPassword string `goconf:"root:password"`
}
func ReloadConfig ¶
Click to show internal directories.
Click to hide internal directories.