package module
Version: v0.0.0-...-fad388b Latest Latest

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

Go to latest
Published: Oct 21, 2016 License: MIT Imports: 22 Imported by: 0



Appgo is a mobile app backend solution that bundles negroni, gorm and other utilities




View Source
const (
	ECodeOK                      ErrCode = 20000
	ECodeRedirect                        = 30200
	ECodeBadRequest                      = 40000
	ECodeUnauthorized                    = 40100
	ECodeForbidden                       = 40300
	ECodeNotFound                        = 40400
	ECodeInternal                        = 50000
	ECode3rdPartyAuthFailed              = 50300
	ECodeInvalidUsername                 = 60001
	ECodeInvalidNickname                 = 60002
	ECodeInvalidPassword                 = 60003
	ECodeMobileUserNotFound              = 60101
	ECodeMobileUserBadCode               = 60102
	ECodeMobileUserBadToken              = 60103
	ECodeMobileUserAlreadyExists         = 60104
View Source
const (
	RoleAppUser  Role = 100
	RoleWebUser       = 101
	RoleWebAdmin      = 200
View Source
const AnonymousId = 6666
View Source
const CustomConfVerHeaderName = "X-Appgo-Conf-Version"
View Source
const CustomTokenHeaderName = "X-Appgo-Token"
View Source
const CustomVersionHeaderName = "X-Appgo-Api-Version"
View Source
const InternalTestId = 7777
View Source
const InternalTestToken = "sjadfjlksadfjkljfwoeifshgsdhgsldfjf"


View Source
var Conf struct {
	DevMode      bool
	LogLevel     log.Level
	RootKey      string
	TemplatePath string
	CdnDomain    string
	Pprof        struct {
		Enable bool
		Port   string
	Mysql []struct {
		Host        string
		Port        string
		User        string
		Password    string
		DbName      string
		Charset     string
		MaxConn     int
		MaxLifetime int
	Redis struct {
		Host        string
		Port        string
		Password    string
		MaxIdle     int
		IdleTimeout int
	Negroni struct {
		Port string
		GZip bool
	Cors struct {
		AllowedOrigins     string
		AllowedMethods     string
		AllowedHeaders     string
		OptionsPassthrough bool
		Debug              bool
	TokenLifetime struct {
		AppUser  int
		WebUser  int
		WebAdmin int
	Weixin struct {
		AppId  string
		Secret string
	WeixinJssdk struct {
		AppId  string
		Secret string
	Weibo struct {
		AppId       string
		Secret      string
		RedirectUrl string
	Qq struct {
		AppId string
	Qiniu struct {
		AccessKey      string
		Secret         string
		Bucket         string
		Domain         string
		DefaultExpires int
		UseHttps       bool
	Umeng struct {
		Android struct {
			AppKey          string
			AppMasterSecret string
		Ios struct {
			AppKey          string
			AppMasterSecret string
	Leancloud struct {
		AppId              string
		AppKey             string
		AndroidAction      string
		ExpirationInterval int
	Graylog struct {
		Ip       string
		Port     string
		Facility string
	Prometheus struct {
		Enable bool
		Port   string
View Source
var (
	RootDir string


func InitLogHooks

func InitLogHooks(skip int)

func SetLogFile

func SetLogFile(f *os.File, withstd bool)


type ApiError

type ApiError struct {
	Code ErrCode `json:"errcode"`
	Msg  string  `json:"errmsg"`
var (
	NotFoundErr                *ApiError
	UnauthorizedErr            *ApiError
	ForbiddenErr               *ApiError
	InternalErr                *ApiError
	InvalidUsernameErr         *ApiError
	InvalidNicknameErr         *ApiError
	InvalidPasswordErr         *ApiError
	MobileUserNotFoundErr      *ApiError
	MobileUserBadCodeErr       *ApiError
	MobileUserBadTokenErr      *ApiError
	MobileUserAlreadyExistsErr *ApiError

func ApiErrFromGoErr

func ApiErrFromGoErr(err error) *ApiError

func NewApiErr

func NewApiErr(code ErrCode, msg string) *ApiError

func NewApiErrWithCode

func NewApiErrWithCode(code ErrCode) *ApiError

func NewApiErrWithMsg

func NewApiErrWithMsg(msg string) *ApiError

func (*ApiError) Error

func (e *ApiError) Error() string

func (*ApiError) HttpCode

func (e *ApiError) HttpCode() int

func (*ApiError) HttpError

func (e *ApiError) HttpError(w http.ResponseWriter)

type DummyInput

type DummyInput struct{}

type ErrCode

type ErrCode int

type FileInfoHook

type FileInfoHook struct {
	// contains filtered or unexported fields

func (*FileInfoHook) Fire

func (hook *FileInfoHook) Fire(entry *logrus.Entry) error

func (*FileInfoHook) Levels

func (hook *FileInfoHook) Levels() []logrus.Level

type Id

type Id int64

func IdFromBase64

func IdFromBase64(str string) Id

func IdFromStr

func IdFromStr(str string) Id

func IdMax

func IdMax() Id

func (Id) Base64

func (id Id) Base64() string

func (Id) MarshalJSON

func (id Id) MarshalJSON() ([]byte, error)

func (Id) String

func (id Id) String() string

func (*Id) UnmarshalJSON

func (id *Id) UnmarshalJSON(b []byte) error

type KvStore

type KvStore interface {
	Set(k, v string, timeout int) error
	Get(k string) (string, error)

type MobileMsgSender

type MobileMsgSender interface {
	SendMobileCode(mobile string, template SmsTemplate, code string) error

type Platform

type Platform int8
const (
	PlatformIos Platform

type PushData

type PushData struct {
	Title       string
	Message     string
	Sound       string
	Badge       int
	PlayVibrate bool
	PlayLights  bool
	PlaySound   bool
	Custom      map[string]interface{}

type PushInfo

type PushInfo struct {
	Platform Platform
	Provider string
	Token    string

type Pusher

type Pusher interface {
	Name() string
	PushNotif(pushInfo map[Id]*PushInfo, content *PushData)

type Role

type Role int

type Sex

type Sex int8
const (
	SexDefault Sex = iota

type SmsTemplate

type SmsTemplate int
const (
	SmsTemplateRegister SmsTemplate

Jump to

Keyboard shortcuts

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