Documentation ¶
Index ¶
- Constants
- Variables
- func ConcurrencyLimit(limit int, normal, fail gin.HandlerFunc) gin.HandlerFunc
- func DbsIsEmpty() bool
- func GlobalMiddleware(middle ...gin.HandlerFunc)
- func Interceptor(authentication Authentication, db *gorm.DB, fail gin.HandlerFunc) (enforcer *casbin.Enforcer, handle gin.HandlerFunc)
- func InterceptorByEnforcer(authentication Authentication, enforcer *casbin.Enforcer, fail gin.HandlerFunc) (handle gin.HandlerFunc)
- func PageNumAndPageCountCheck(pageNum, pageCount int64) error
- func Run(api ApiFunc)
- type ApiFunc
- type Authentication
- type DatabaseConfig
- type DbSet
- type DefaultClaims
- type DefaultToken
- type OnlineSessionSet
- type PageParam
- type PageResult
- type Pro
- type Request
- type Resp
- type RespData
- type Session
- type StaticRes
- type YamlConfig
Constants ¶
View Source
const ( Abnormal = iota - 1 Normal NotLogin LoginExpired LoginFail PageNumCanNotBeZero PageCountCanNotBeZero NotFound )
View Source
const ( DevMode = "dev" ProMode = "pro" TraceLog = "trace" DebugLog = "debug" InfoLog = "info" WarnLog = "warn" ErrorLog = "error" FatalLog = "fatal" PanicLog = "panic" TextFormatter = "text" JSONFormatter = "json" )
Variables ¶
View Source
var Dbs = DbSet{}
View Source
var Group *gin.RouterGroup
View Source
var Logger = ¢erLogger{}
View Source
var LoginExpiredResp = Resp{"errorCode": LoginExpired, "errorMsg": "login expired"}
View Source
var LoginFailResp = Resp{"errorCode": LoginFail, "errorMsg": "login fail"}
View Source
var NotLoginResp = Resp{"errorCode": NotLogin, "errorMsg": "not login"}
View Source
var PageCountCanNotBeZeroErr = errors.New("page count cannot be less than zero")
View Source
var PageCountCanNotBeZeroResp = Resp{"errorCode": PageCountCanNotBeZero, "errorMsg": "page count cannot be less than zero"}
View Source
var PageNotFoundResp = Resp{"errorCode": NotFound, "errorMsg": "not found"}
View Source
var PageNumCanNotBeZeroErr = errors.New("page number cannot be less than zero")
View Source
var PageNumCanNotBeZeroResp = Resp{"errorCode": PageNumCanNotBeZero, "errorMsg": "page number cannot be less than zero"}
View Source
var Rou *gin.Engine
View Source
var SessionMiss = errors.New("session miss")
View Source
var SystemErrorResp = Resp{"errorCode": Abnormal, "errorMsg": "system error"}
View Source
var TokenExpired = errors.New("token expired")
View Source
var TokenInvalid = errors.New("token invalid")
View Source
var TokenMalformed = errors.New("token error")
View Source
var TokenNotValidYet = errors.New("token not valid yet")
Functions ¶
func ConcurrencyLimit ¶
func ConcurrencyLimit(limit int, normal, fail gin.HandlerFunc) gin.HandlerFunc
func DbsIsEmpty ¶
func DbsIsEmpty() bool
func GlobalMiddleware ¶
func GlobalMiddleware(middle ...gin.HandlerFunc)
func Interceptor ¶
func Interceptor(authentication Authentication, db *gorm.DB, fail gin.HandlerFunc) (enforcer *casbin.Enforcer, handle gin.HandlerFunc)
func InterceptorByEnforcer ¶
func InterceptorByEnforcer(authentication Authentication, enforcer *casbin.Enforcer, fail gin.HandlerFunc) (handle gin.HandlerFunc)
Types ¶
type Authentication ¶
type DatabaseConfig ¶
type DefaultClaims ¶
type DefaultToken ¶
type DefaultToken struct {
SigningKey []byte
}
func (*DefaultToken) Create ¶
func (t *DefaultToken) Create(claims DefaultClaims) (string, error)
func (*DefaultToken) Parse ¶
func (t *DefaultToken) Parse(tokenString string) (*DefaultClaims, error)
type OnlineSessionSet ¶
type OnlineSessionSet struct {
// contains filtered or unexported fields
}
func NewOnline ¶
func NewOnline(sessions map[int]*Session) *OnlineSessionSet
func (*OnlineSessionSet) Add ¶
func (on *OnlineSessionSet) Add(s Session)
func (*OnlineSessionSet) Counts ¶
func (on *OnlineSessionSet) Counts() int
func (*OnlineSessionSet) Delete ¶
func (on *OnlineSessionSet) Delete(id int) *Session
type PageResult ¶
func MysqlPage ¶
func MysqlPage(param PageParam, slice interface{}, db *gorm.DB, sql string, values ...interface{}) (pr PageResult, err error)
slice must be pointer type
func (PageResult) String ¶
func (p PageResult) String() string
type YamlConfig ¶
type YamlConfig struct { ContextName string `yaml:"contextName"` ServerName string `yaml:"serverName"` Statics []StaticRes `yaml:",flow"` Database []DatabaseConfig `yaml:"database,flow"` Port int RunMode string `yaml:"runMode"` DisableConsoleLog bool `yaml:"disableConsoleLog"` ConsoleLogLevel string `yaml:"consoleLogLevel"` LogFileOutLevels []string `yaml:"logFileOutLevels,flow"` EnableLogFileOut bool `yaml:"enableLogFileOut"` LogFormatType string `yaml:"logFormatType"` EnableHttps bool `yaml:"enableHttps"` CertFile string `yaml:"certFile"` KeyFile string `yaml:"keyFile"` HtmlTemplateDir string `yaml:"htmlTemplateDir"` }
var Config YamlConfig
Click to show internal directories.
Click to hide internal directories.