Documentation ¶
Index ¶
- Constants
- func NewGracefulListener(address string, maxWaitTime time.Duration) net.Listener
- func SetGatewayRateLimiter(option rate.Option)
- func SetMethodRateLimiter(option rate.Option)
- func SetUserRateLimiter(option rate.Option)
- type CacheAware
- type Configs
- type Context
- func (self *Context) AddStorage(k string, v interface{})
- func (self *Context) Authenticated() bool
- func (self *Context) ClientDevice() string
- func (self *Context) ClientLanguage() string
- func (self *Context) DelStorage(k string)
- func (self *Context) GetHmac256Sign(d, n string, t, p int64, key string) string
- func (self *Context) GetJwtConfig() jwt.JwtConfig
- func (self *Context) GetStorage(k string) interface{}
- func (self *Context) GetTokenSecret() string
- func (self *Context) Handle() error
- func (self *Context) Json(data interface{}) error
- func (self *Context) Parser(dst interface{}) error
- func (self *Context) RemoteIP() string
- func (self *Context) Text(data string) error
- type DefaultCacheSessionAware
- func (self *DefaultCacheSessionAware) CreateSession(s Session) error
- func (self *DefaultCacheSessionAware) DeleteSession(s Session) error
- func (self *DefaultCacheSessionAware) GetActiveSessions() []Session
- func (self *DefaultCacheSessionAware) ReadSession(s string) (Session, error)
- func (self *DefaultCacheSessionAware) UpdateSession(s Session) error
- type Filter
- type FilterObject
- type GatewayRateLimiterFilter
- type GracefulListener
- type HookNode
- type HttpLog
- type HttpNode
- func (self *HttpNode) AddCache(cacheAware CacheAware)
- func (self *HttpNode) AddCipher(cipher crypto.Cipher)
- func (self *HttpNode) AddFilter(object *FilterObject)
- func (self *HttpNode) AddJwtConfig(config jwt.JwtConfig)
- func (self *HttpNode) AddLanguage(langDs, filePath string) error
- func (self *HttpNode) AddRoleRealm(roleRealm func(ctx *Context, onlyRole bool) (*Permission, error)) error
- func (self *HttpNode) ClearFilterChain()
- func (self *HttpNode) DELETE(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) EnableECC(enable bool)
- func (self *HttpNode) GET(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) HEAD(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) Json(ctx *Context, data interface{}) error
- func (self *HttpNode) OPTIONS(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) PATCH(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) POST(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) PUT(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
- func (self *HttpNode) SetSystem(name, version string)
- func (self *HttpNode) StartServer(addr string)
- func (self *HttpNode) Text(ctx *Context, data string) error
- type JWTSession
- func (self *JWTSession) GetAttribute(k string) (interface{}, error)
- func (self *JWTSession) GetAttributeKeys() ([]string, error)
- func (self *JWTSession) GetHost() string
- func (self *JWTSession) GetId() string
- func (self *JWTSession) GetLastAccessTime() int64
- func (self *JWTSession) GetStartTimestamp() int64
- func (self *JWTSession) GetTimeout() (int64, error)
- func (self *JWTSession) Invalid() bool
- func (self *JWTSession) IsTimeout() bool
- func (self *JWTSession) RemoveAttribute(k string) error
- func (self *JWTSession) SetAttribute(k string, v interface{}) error
- func (self *JWTSession) SetHost(host string)
- func (self *JWTSession) SetTimeout(t int64) error
- func (self *JWTSession) Stop() error
- func (self *JWTSession) Touch() error
- func (self *JWTSession) Validate(accessToken, secretKey string) (int64, error)
- type JsonBody
- type JsonResp
- type ParameterFilter
- type Permission
- type PostHandle
- type PostHandleFilter
- type RenderHandleFilter
- type Response
- type RoleFilter
- type RouterConfig
- type Session
- type SessionAware
- type SessionFilter
- type System
- type UserRateLimiterFilter
Constants ¶
View Source
const ( GatewayRateLimiterFilterName = "GatewayRateLimiterFilter" ParameterFilterName = "ParameterFilter" SessionFilterName = "SessionFilter" UserRateLimiterFilterName = "UserRateLimiterFilter" RoleFilterName = "RoleFilter" PostHandleFilterName = "PostHandleFilter" RenderHandleFilterName = "RenderHandleFilter" )
View Source
const ( UTF8 = "UTF-8" ANDROID = "android" IOS = "ios" WEB = "web" TEXT_PLAIN = "text/plain; charset=utf-8" APPLICATION_JSON = "application/json; charset=utf-8" GET = "GET" POST = "POST" PUT = "PUT" PATCH = "PATCH" DELETE = "DELETE" HEAD = "HEAD" OPTIONS = "OPTIONS" MAX_VALUE_LEN = 200000 // 最大参数值长度 MAX_TOKEN_LEN = 2048 // 最大Token值长度 MAX_CODE_LEN = 1024 // 最大Code值长度 Authorization = "Authorization" RandomCode = "RandomCode" )
Variables ¶
This section is empty.
Functions ¶
func NewGracefulListener ¶
NewGracefulListener wraps the given listener into 'graceful shutdown' listener.
func SetGatewayRateLimiter ¶
func SetMethodRateLimiter ¶
func SetUserRateLimiter ¶
Types ¶
type Context ¶
type Context struct { CacheAware func(ds ...string) (cache.Cache, error) Method string Path string System *System RequestCtx *fasthttp.RequestCtx Subject *jwt.Subject JsonBody *JsonBody Response *Response RouterConfig *RouterConfig RSA crypto.Cipher Storage map[string]interface{} // contains filtered or unexported fields }
func (*Context) AddStorage ¶
func (*Context) Authenticated ¶
func (*Context) ClientDevice ¶ added in v1.0.104
func (*Context) ClientLanguage ¶ added in v1.0.107
func (*Context) DelStorage ¶ added in v1.0.3
func (*Context) GetHmac256Sign ¶
func (*Context) GetJwtConfig ¶
func (*Context) GetStorage ¶
func (*Context) GetTokenSecret ¶
type DefaultCacheSessionAware ¶
type DefaultCacheSessionAware struct {
// contains filtered or unexported fields
}
func NewLocalCacheSessionAware ¶
func NewLocalCacheSessionAware() *DefaultCacheSessionAware
func (*DefaultCacheSessionAware) CreateSession ¶
func (self *DefaultCacheSessionAware) CreateSession(s Session) error
func (*DefaultCacheSessionAware) DeleteSession ¶
func (self *DefaultCacheSessionAware) DeleteSession(s Session) error
func (*DefaultCacheSessionAware) GetActiveSessions ¶
func (self *DefaultCacheSessionAware) GetActiveSessions() []Session
func (*DefaultCacheSessionAware) ReadSession ¶
func (self *DefaultCacheSessionAware) ReadSession(s string) (Session, error)
func (*DefaultCacheSessionAware) UpdateSession ¶
func (self *DefaultCacheSessionAware) UpdateSession(s Session) error
type FilterObject ¶
type GatewayRateLimiterFilter ¶
type GatewayRateLimiterFilter struct{}
type GracefulListener ¶
type GracefulListener struct {
// contains filtered or unexported fields
}
func (*GracefulListener) Addr ¶
func (ln *GracefulListener) Addr() net.Addr
func (*GracefulListener) Close ¶
func (ln *GracefulListener) Close() error
Close closes the inner listener and waits until all the pending open connections are closed before returning.
type HttpNode ¶
type HttpNode struct { HookNode // contains filtered or unexported fields }
func (*HttpNode) AddCache ¶ added in v1.0.5
func (self *HttpNode) AddCache(cacheAware CacheAware)
func (*HttpNode) AddFilter ¶
func (self *HttpNode) AddFilter(object *FilterObject)
func (*HttpNode) AddJwtConfig ¶
func (*HttpNode) AddLanguage ¶ added in v1.0.107
func (*HttpNode) AddRoleRealm ¶ added in v1.0.115
func (*HttpNode) ClearFilterChain ¶
func (self *HttpNode) ClearFilterChain()
func (*HttpNode) DELETE ¶
func (self *HttpNode) DELETE(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) GET ¶
func (self *HttpNode) GET(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) HEAD ¶
func (self *HttpNode) HEAD(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) OPTIONS ¶
func (self *HttpNode) OPTIONS(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) PATCH ¶
func (self *HttpNode) PATCH(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) POST ¶
func (self *HttpNode) POST(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) PUT ¶
func (self *HttpNode) PUT(path string, handle func(ctx *Context) error, routerConfig *RouterConfig)
func (*HttpNode) StartServer ¶
type JWTSession ¶
type JWTSession struct { Id string StartTimestamp int64 LastAccessTime int64 Timeout int64 StopTime int64 Host string Expire bool Attributes map[string]interface{} }
func (*JWTSession) GetAttribute ¶
func (self *JWTSession) GetAttribute(k string) (interface{}, error)
func (*JWTSession) GetAttributeKeys ¶
func (self *JWTSession) GetAttributeKeys() ([]string, error)
func (*JWTSession) GetHost ¶
func (self *JWTSession) GetHost() string
func (*JWTSession) GetId ¶
func (self *JWTSession) GetId() string
func (*JWTSession) GetLastAccessTime ¶
func (self *JWTSession) GetLastAccessTime() int64
func (*JWTSession) GetStartTimestamp ¶
func (self *JWTSession) GetStartTimestamp() int64
func (*JWTSession) GetTimeout ¶
func (self *JWTSession) GetTimeout() (int64, error)
func (*JWTSession) Invalid ¶
func (self *JWTSession) Invalid() bool
func (*JWTSession) IsTimeout ¶
func (self *JWTSession) IsTimeout() bool
func (*JWTSession) RemoveAttribute ¶
func (self *JWTSession) RemoveAttribute(k string) error
func (*JWTSession) SetAttribute ¶
func (self *JWTSession) SetAttribute(k string, v interface{}) error
func (*JWTSession) SetHost ¶
func (self *JWTSession) SetHost(host string)
func (*JWTSession) SetTimeout ¶
func (self *JWTSession) SetTimeout(t int64) error
func (*JWTSession) Stop ¶
func (self *JWTSession) Stop() error
func (*JWTSession) Touch ¶
func (self *JWTSession) Touch() error
type JsonBody ¶
type JsonBody struct { Data interface{} `json:"d"` Time int64 `json:"t"` Nonce string `json:"n"` Plan int64 `json:"p"` // 0.默认(登录状态) 1.AES(登录状态) 2.RSA/ECC模式(匿名状态) 3.独立验签模式(匿名状态) Sign string `json:"s"` }
type ParameterFilter ¶
type ParameterFilter struct{}
type Permission ¶
type PostHandle ¶
type PostHandleFilter ¶
type PostHandleFilter struct{}
type RenderHandleFilter ¶
type RenderHandleFilter struct{}
type RoleFilter ¶
type RoleFilter struct{}
type RouterConfig ¶
type Session ¶
type Session interface { GetId() string GetStartTimestamp() int64 GetLastAccessTime() int64 GetTimeout() (int64, error) // 抛出校验会话异常 SetTimeout(t int64) error // 抛出校验会话异常 SetHost(host string) GetHost() string Touch() error // 刷新最后授权时间,抛出校验会话异常 Stop() error // 抛出校验会话异常 GetAttributeKeys() ([]string, error) // 抛出校验会话异常 GetAttribute(k string) (interface{}, error) // 抛出校验会话异常 SetAttribute(k string, v interface{}) error // 抛出校验会话异常 RemoveAttribute(k string) error // 抛出校验会话异常 Validate(accessToken, secretKey string) (int64, error) // 校验会话 Invalid() bool // 判断会话是否有效 IsTimeout() bool // 判断会话是否已超时 }
type SessionAware ¶
type SessionAware interface { CreateSession(s Session) error // 保存session ReadSession(s string) (Session, error) // 通过id读取session,抛出未知session异常 UpdateSession(s Session) error // 更新session,抛出未知session异常 DeleteSession(s Session) error // 删除session,抛出未知session异常 GetActiveSessions() []Session // 获取活动的session集合 }
type SessionFilter ¶
type SessionFilter struct{}
type UserRateLimiterFilter ¶
type UserRateLimiterFilter struct{}
Click to show internal directories.
Click to hide internal directories.