Documentation
¶
Index ¶
- Constants
- Variables
- func CurrGHead(ctx context.Context, key string) string
- func CurrentUId(c *gin.Context) int64
- func Init(mode string, transJwtTokenForGrpc ...bool)
- func InitJwtAuth(name string, cust ICustClaimer, signKey string) error
- func InstallExt(ctrlName string, mc IMCGeter, conf *Config)
- func JWT(key []byte) *_jwt
- func MH_Cors(allowOrigins ...string) gin.HandlerFunc
- func MH_Corss() gin.HandlerFunc
- func MH_CurrentUser() gin.HandlerFunc
- func MH_Heavier(level time.Duration) gin.HandlerFunc
- func MH_JWTAuthed(name string) gin.HandlerFunc
- func MH_SESAuthed() gin.HandlerFunc
- func MH_Session(secret string) gin.HandlerFunc
- func PreUnregist(name string) error
- func Service(c *gin.Context, s IService)
- func ServiceHtml(c *gin.Context, name string, s IService)
- func ServiceStr(c *gin.Context, s IService)
- func ServiceXml(c *gin.Context, s IService)
- func Sessions(c *gin.Context) sessions.Session
- func TranGHead(ctx context.Context, c *gin.Context, keys ...string) context.Context
- func WithGHead(ctx context.Context, key string, valStringer interface{}) context.Context
- type CliResp
- type Config
- type ECode
- type EStatus
- type GinLogger
- type GinRecover
- type Htp
- type IApier
- type ICustClaimer
- type IMCGeter
- type IService
- type IUser
- type ListenTLS
- type MUser
- type Response
- func RespConvertErr(msg string, err error) Response
- func RespDBErr(msg string, err error) Response
- func RespErr(errCode ECode, msg string, err error) Response
- func RespErrData(errCode ECode, msg string, err error, data interface{}) Response
- func RespFile(c *gin.Context, filePath string) Response
- func RespFileData(c *gin.Context, contentType, fileName string, data []byte) Response
- func RespModelErr(msg string, err error) Response
- func RespOK(msg string, data interface{}) Response
- func RespParamErr(msg string, err error) Response
- func RespValidErr(err error) Response
- type TUnits
- type TUserGeterFunc
- type Unit
Constants ¶
View Source
const ( DEF_UNIT_MSIZE = 10 DEF_CLAIMS_HEAD_KEY = "claims" // request head 中 jwt_claims 字段 DEF_REQUEST_TIMEOVER = time.Second * 10 // 等待回应的请求超时时间 )
Variables ¶
View Source
var ( TokenExpired error = errors.New("Token is expired") TokenNotValidYet error = errors.New("Token not active yet") TokenMalformed error = errors.New("That's not even a token") TokenInvalid error = errors.New("Token is invalid") AuthNameExisted error = errors.New("Jwt auth unit already exists") RequestExpireTime float64 = 3000 )
一些常量
Functions ¶
func CurrentUId ¶
------------------------------------------------------------------------------ ===================================User Auth==================================== ------------------------------------------------------------------------------ CurrentUser 获取用户Id
func InitJwtAuth ¶
func InitJwtAuth(name string, cust ICustClaimer, signKey string) error
-------- JWT认证中间件
func JWT ¶
func JWT(key []byte) *_jwt
------------------------------------------------------------------------------ ==================================JWT签名工具结构================================= ------------------------------------------------------------------------------
func MH_JWTAuthed ¶
func MH_JWTAuthed(name string) gin.HandlerFunc
func ServiceStr ¶
func ServiceXml ¶
Types ¶
type Config ¶
type Config struct { RunMode string `json:"runMode"` // ListenAddr string `json:"listenAddr"` ListnTls ListenTLS `json:"listnTls"` }
=> 启动配置
type ECode ¶
type ECode = int
=> 错误码定义[3位数:复用http原本语义]
const ( CodeSucessed ECode = 0 // http.StatusOK CodeTokenNil ECode = -1 // Head中没有携带token CodeTokenErr ECode = -2 // token错误 CodeTokenExpired ECode = -3 // token过期 CodeTokenMake ECode = -4 // token生成失败 CodeNotLogin ECode = -5 // 未登录 CodeNoRight ECode = -6 // 未授权访问 CodeAuthFaild ECode = -7 // 认证错误 CodeSysError ECode = -9 // 系统错误 CodeDBError ECode = -10 // 数据库错误 CodeParamErr ECode = -11 // 参数错误 CodeEncrypt ECode = -15 // 加密解密错误 CodeAuthStamp ECode = -16 // 时间戳错误 CodeAuthHash ECode = -17 // Hash错误 CodeTargetNotFound ECode = -18 // 找不到目标 CodeModelError ECode = -19 // 模型层逻辑错误 CodePermitDenied ECode = -20 // 不允许访问 CodePermitRdsRole ECode = -21 // 许可错误[role] CodePermitRdsRoute ECode = -22 // 许可错误[Route] CodePermitLoginClash ECode = -23 // 账号登陆冲突 CodePermitChanged ECode = -24 // 权限发生改变 CodeConvertError ECode = -25 // 结构转换错误 CodeSortField ECode = -26 // 不支持的排序字段 CodeGrpcBase ECode = 100 // GRPC返回的状态码额外加100 )
type Htp ¶
type Htp struct { cto.ControlBase // contains filtered or unexported fields }
=> etcd client control
func (*Htp) HandleInit ¶
func (this *Htp) HandleInit()
func (*Htp) HandleTerm ¶
func (this *Htp) HandleTerm()
type ICustClaimer ¶
type ICustClaimer interface { jwt.Claims TheUID() int64 TheStandardClaims() *jwt.StandardClaims }
type IUser ¶
type Response ¶
type Response struct { Code ECode `json:"code"` Data interface{} `json:"data"` Msg string `json:"msg"` Error string `json:"err,omitempty"` // contains filtered or unexported fields }
Response 基础序列化器
func RespErrData ¶
通用错误处理数据
func RespFileData ¶
文件流返回
type TUserGeterFunc ¶
Click to show internal directories.
Click to hide internal directories.