Documentation ¶
Index ¶
- Variables
- func BindXML(c Context, obj interface{}) error
- func CORSMiddleware() gin.HandlerFunc
- func CORSMiddleware2(skippers ...res.SkipperFunc) gin.HandlerFunc
- func CmdWeb(ctx context.Context, action func(c *cli.Context) error) *cli.Command
- func FixResponse400Error(c Context, err error, errfunc func())
- func FixResponse401Error(c Context, err error, errfunc func())
- func FixResponse403Error(c Context, err error, errfunc func())
- func FixResponse406Error(c Context, err error, errfunc func())
- func FixResponse500Error(c Context, err error, errfunc func())
- func FixResponse500Error2Logger(c Context, err error)
- func FixResponseError(c Context, err error) bool
- func GetAcceptLanguage(c *gin.Context) string
- func GetBearerToken(ctx context.Context) (string, error)
- func GetClientIP(c *gin.Context) string
- func GetCookieToken(ctx context.Context) (string, error)
- func GetCtxValue(ctx context.Context, key string) (interface{}, bool)
- func GetCtxValueToString(ctx context.Context, key string) (string, bool)
- func GetHostIP(c *gin.Context) string
- func GetQueryToken(ctx context.Context) (string, error)
- func GetTraceID(c *gin.Context) string
- func GetUserInfo(c *gin.Context) (auth.UserInfo, bool)
- func GizMiddleware() gin.HandlerFunc
- func HandlerFunc(fx res.HandlerFunc) gin.HandlerFunc
- func HandlerFunc2(fx res.HandlerFunc, nc func(*gin.Context) res.Context) gin.HandlerFunc
- func I18nMiddleware(bundle *i18n.Bundle) gin.HandlerFunc
- func InitGinEngine(opt UseEngine) *gin.Engine
- func NoMethodHandler(c *gin.Context)
- func NoRouteHandler(c *gin.Context)
- func ParseForm(c Context, obj interface{}) error
- func ParseJSON(c Context, obj interface{}) error
- func ParseQuery(c Context, obj interface{}) error
- func RecoveryMiddleware() gin.HandlerFunc
- func ResError(ctx Context, em *res.ErrorModel) error
- func ResJSON(ctx Context, status int, v interface{})
- func ResSuccess(ctx Context, v interface{}) error
- func Run(ctx context.Context, opts ...Option) error
- func RunHTTPServer(ctx context.Context, handler http.Handler) func()
- func RunServer(ctx context.Context, opts ...Option) (func(), error)
- func RunWeb(app *cli.App, run func(ctx context.Context, opts ...Option) error)
- func RunWithShutdown(ctx context.Context, runServer func() (func(), error)) error
- func SetCtxValue(ctx context.Context, key string, value interface{}) bool
- func SetUserInfo(c *gin.Context, user auth.UserInfo)
- func UseAuthServerMiddleware(c *gin.Context, ...)
- func UseAuthxClientMiddleware(c *gin.Context)
- func UseAuthzClientMiddleware(c *gin.Context)
- func UseRemoteAuth(c *gin.Context, user *SigninUser, authz string) bool
- func WWWMiddleware(root string, skippers ...res.SkipperFunc) gin.HandlerFunc
- type BuildInjector
- type Context
- type GinContext
- func (a *GinContext) FormatMessage(emsg *i18n.Message, args map[string]interface{}) string
- func (a *GinContext) GetRequest() *http.Request
- func (a *GinContext) GetTraceCIP() string
- func (a *GinContext) GetTraceID() string
- func (a *GinContext) GetTraceUID() string
- func (a *GinContext) GetUserInfo() auth.UserInfo
- type Healthz
- type Option
- type Options
- type Router
- type SigninUser
- func (u *SigninUser) GetAccount() string
- func (u *SigninUser) GetAccount1() string
- func (u *SigninUser) GetAccount2() string
- func (u *SigninUser) GetAccountIdx() int64
- func (u *SigninUser) GetAgent() string
- func (u *SigninUser) GetAudience() string
- func (u *SigninUser) GetDomain() string
- func (u *SigninUser) GetIssuer() string
- func (u *SigninUser) GetOrgAdmin() string
- func (u *SigninUser) GetOrgCode() string
- func (u *SigninUser) GetOrgUsrID() string
- func (u *SigninUser) GetScope() string
- func (u *SigninUser) GetTokenID() string
- func (u *SigninUser) GetTokenPID() string
- func (u *SigninUser) GetUserID() string
- func (u *SigninUser) GetUserIdx() int64
- func (u *SigninUser) GetUserName() string
- func (u *SigninUser) GetUserRoles() []string
- func (u *SigninUser) GetUserSvcRoles(svc string) []string
- func (u *SigninUser) SetUserRoles(roles []string)
- type Status
- type SysStatus
- type UseEngine
- type UserIdx
Constants ¶
This section is empty.
Variables ¶
var (
DEBUG = false
)
Functions ¶
func CORSMiddleware2 ¶
func CORSMiddleware2(skippers ...res.SkipperFunc) gin.HandlerFunc
CORSMiddleware2 跨域 不推荐使用,可以使用gin中的跨域处理
func FixResponse400Error ¶
FixResponse400Error 修复返回的异常
func FixResponse401Error ¶
FixResponse401Error 修复返回的异常, 注意, 401异常会导致系统重定向到登陆页面
func FixResponse403Error ¶
FixResponse403Error 修复返回的异常
func FixResponse406Error ¶
FixResponse406Error 修复返回的异常
func FixResponse500Error ¶
FixResponse500Error 修复返回的异常
func FixResponse500Error2Logger ¶
FixResponse500Error2Logger 修复返回的异常
func FixResponseError ¶
FixResponseError 上级应用已经处理了返回值
func GetBearerToken ¶
GetBearerToken 获取用户令牌
func GetCookieToken ¶
GetCookieToken 获取用户令牌
func GetCtxValue ¶
GetCtxValue 获取令牌加密方式
func GetCtxValueToString ¶
GetCtxValueToString 获取令牌加密方式
func GizMiddleware ¶
func GizMiddleware() gin.HandlerFunc
GizMiddleware Giz, 主要部署前端时候(www中间件)对静态资源进行压缩
func HandlerFunc ¶
func HandlerFunc(fx res.HandlerFunc) gin.HandlerFunc
HandlerFunc -> res.HandlerFunc -> gin.HandlerFunc
func HandlerFunc2 ¶
func HandlerFunc2(fx res.HandlerFunc, nc func(*gin.Context) res.Context) gin.HandlerFunc
HandlerFunc2 -> res.HandlerFunc -> gin.HandlerFunc
func ParseQuery ¶
ParseQuery 解析Query参数, 注意,解析失败后需要直接返回
func ResSuccess ¶
ResSuccess 包装响应错误 禁止service层调用,请使用NewSuccess替换
func RunHTTPServer ¶
RunHTTPServer 初始化http服务
func RunWithShutdown ¶
RunWithShutdown 运行服务
func SetCtxValue ¶
SetCtxValue 配置令牌加密方式
func UseAuthServerMiddleware ¶
func UseAuthServerMiddleware(c *gin.Context, gf func(*gin.Context, auth.UserInfo) (aid, uid int64, err error))
UseAuthServerMiddleware 用户授权中间件
func UseAuthxClientMiddleware ¶
UseAuthxClientMiddleware 用户授权中间件, 只判定登录权限
func UseAuthzClientMiddleware ¶
UseAuthzClientMiddleware 用户授权中间件, 只判定登录权限
func UseRemoteAuth ¶
func UseRemoteAuth(c *gin.Context, user *SigninUser, authz string) bool
UseRemoteAuthz ... proxy_set_header X-Request-Id $req_id; proxy_set_header X-Request-Origin-Host $host; proxy_set_header X-Request-Origin-Path $request_uri; proxy_set_header X-Request-Origin-Method $request_method;
func WWWMiddleware ¶
func WWWMiddleware(root string, skippers ...res.SkipperFunc) gin.HandlerFunc
WWWMiddleware 静态站点中间件
Types ¶
type BuildInjector ¶
BuildInjector 构建注入器的方法
type Context ¶
type Context interface { logger.ContextTrace context.Context res.Context GetUserInfo() auth.UserInfo // 获取登陆用户信息 ShouldBindWith(obj interface{}, b binding.Binding) error // bind Data(int, string, []byte) // 写入数据 Redirect(int, string) // 重定向RX }
func NewContext ¶
type GinContext ¶
func (*GinContext) FormatMessage ¶
func (a *GinContext) FormatMessage(emsg *i18n.Message, args map[string]interface{}) string
FormatMessage ...
type Options ¶
type Options struct { ConfigFile string Version string BuildInjector BuildInjector }
Options options
type SigninUser ¶
type SigninUser struct { TokenID string `header:"X-Request-Z-Token-Kid"` TokenPID string `header:"X-Request-Z-Token-Pid"` AccoIdx int64 `header:"X-Request-Z-Account-Id"` UserIdx int64 `header:"X-Request-Z-User-Id"` Account string `header:"X-Request-Z-Account"` Account1 string `header:"X-Request-Z-Account1"` Account2 string `header:"X-Request-Z-Account2"` UserID string `header:"X-Request-Z-User-Kid"` UserName string `header:"X-Request-Z-User-Name"` UserRoles string `header:"X-Request-Z-User-Roles"` OrgCode string `header:"X-Request-Z-Org-Code"` OrgAdmin string `header:"X-Request-Z-Org-Admin"` OrgUsrID string `header:"X-Request-Z-Org-Usrid"` Agent string `header:"X-Request-Z-Agent"` Scope string `header:"X-Request-Z-Scope"` Domain string `header:"X-Request-Z-Domain"` Issuer string `header:"X-Request-Z-Issuer"` Audience string `header:"X-Request-Z-Audience"` ZgoXip string `header:"X-Request-Z-Xip"` }
SigninUser 登陆用户信息
func (*SigninUser) GetUserSvcRoles ¶
func (u *SigninUser) GetUserSvcRoles(svc string) []string
GetUserSvcRoles xxx
func (*SigninUser) SetUserRoles ¶
func (u *SigninUser) SetUserRoles(roles []string)
SetUserRoles xxx
type Status ¶
type Status struct { Uptime string NumGoroutine int // General statistics. MemAllocated string // bytes allocated and still in use MemTotal string // bytes allocated (even if freed) MemSys string // bytes obtained from system (sum of XxxSys below) Lookups uint64 // number of pointer lookups MemMallocs uint64 // number of mallocs MemFrees uint64 // number of frees // Main allocation heap statistics. HeapAlloc string // bytes allocated and still in use HeapSys string // bytes obtained from system HeapIdle string // bytes in idle spans HeapInuse string // bytes in non-idle span HeapReleased string // bytes released to the OS HeapObjects uint64 // total number of allocated objects // Low-level fixed-size structure allocator statistics. // Inuse is bytes used now. // Sys is bytes obtained from system. StackInuse string // bootstrap stacks StackSys string MSpanInuse string // mspan structures MSpanSys string MCacheInuse string // mcache structures MCacheSys string BuckHashSys string // profiling bucket hash table GCSys string // GC metadata OtherSys string // other system allocations // Garbage collector statistics. NextGC string // next run in HeapAlloc time (bytes) LastGC string // last run in absolute time (ns) PauseTotalNs string PauseNs string // circular buffer of recent GC pause times, most recent at [(NumGC+255)%256] NumGC uint32 }
Status 应用状态