Documentation
¶
Overview ¶
Package middleware recommended use: app.UseRouter cors configs
Index ¶
- func GetFromJWT(ctx iris.Context) interface{}
- func JWTSession(ctx iris.Context)
- func NewCORS(cfg *CorsConfig) iris.Handler
- func NewIrisMonitor(cfg *MonitorConfig) iris.Handler
- func NewJWT(cfg *JWTConfig) iris.Handler
- func NewMonitor(cfg *MonitorConfig) *monitor
- func NewRequestLogger(cfg *RequestLogConfig) iris.Handler
- type CorsConfig
- type JWTConfig
- type MonitorConfig
- type RequestLogConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFromJWT ¶
func GetFromJWT(ctx iris.Context) interface{}
GetFromJWT get raw claims info set from config When called this method will need JWTConfig initialed first, call NewJWT if necessary You can get token from the
func JWTSession ¶
func JWTSession(ctx iris.Context)
func NewCORS ¶
func NewCORS(cfg *CorsConfig) iris.Handler
NewCORS POST、PUT、PATCH和DELETE 标准上要求浏览器在这些请求上都要加上 Origin Header CORS 安全策略主要应用于浏览器页面跨域访问的时候,对于非浏览器页面请求,业界通常不予以特殊拦截
func NewIrisMonitor ¶
func NewIrisMonitor(cfg *MonitorConfig) iris.Handler
NewIrisMonitor creates a new Monitor if needed recommended usage is app.UseGlobal not the useRouter function for that attackers may attack on those 404 not found uris, which UseRouter function will count, causing the metrics too heavy
func NewJWT ¶
func NewJWT(cfg *JWTConfig) iris.Handler
NewJWT return the JWT middleware for iris web framework This returned middleware can be used in the project only if you need to set Token only here, also you can use in any project if you want, just make sure the configuration is the same.
func NewMonitor ¶
func NewMonitor(cfg *MonitorConfig) *monitor
func NewRequestLogger ¶
func NewRequestLogger(cfg *RequestLogConfig) iris.Handler
Types ¶
type CorsConfig ¶
type JWTConfig ¶
type JWTConfig struct { Name string `json:"name" yaml:"name"` // Name of the JWT Expire int `json:"expire" yaml:"expire"` // JWT expire time Domain string `json:"domain" yaml:"domain"` // JWT domain Secret string `json:"key" yaml:"key"` // Secret of the JWT Claims func(ctx iris.Context) (interface{}, error) // set if the return value from NewJWT is used as middleware Deserializer func(data []byte) (interface{}, error) // must be set }
JWTConfig Json Web Token config
type MonitorConfig ¶
type MonitorConfig struct { Port int `json:"port" yaml:"port"` Path string `json:"path" yaml:"path"` Tags []string `json:"tags" yaml:"tags"` }
func NewDefaultMonitorCfg ¶
func NewDefaultMonitorCfg() *MonitorConfig
type RequestLogConfig ¶
type RequestLogConfig struct { WithLabels bool `json:"withLabels" yaml:"with-labels"` LogLong bool `json:"logLong" yaml:"log-long"` Threshold int64 `json:"threshold" yaml:"threshold"` }
func DefaultLogConfig ¶
func DefaultLogConfig() *RequestLogConfig