Documentation ¶
Overview ¶
Package plugins
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package limit_req
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Package plugins ¶
@author: xwc1125
Index ¶
- Constants
- Variables
- type BasicAuth
- type BasicAuthConf
- type Cors
- type CorsConf
- type GelfUdpLogger
- type GelfUdpLoggerConf
- type Gzip
- type GzipConf
- type Headers
- type HeadersConf
- type HttpLogger
- type HttpLoggerConf
- type IpRestriction
- type IpRestrictionConf
- type JwtAuth
- type JwtAuthConf
- type LimitReq
- type LimitReqConf
- type MultiResponseRewrite
- func (p *MultiResponseRewrite) Name() string
- func (p *MultiResponseRewrite) ParseConf(in []byte) (interface{}, error)
- func (p *MultiResponseRewrite) Priority() int64
- func (p *MultiResponseRewrite) RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) error
- func (p *MultiResponseRewrite) Version() string
- type MultiResponseRewriteConf
- type OAuth2
- type OAuth2Conf
- type PluginHeadersSTSType
- type PluginMultiResponseRewriteVariantType
- type PluginRedirectRegexVariantType
- type Prometheus
- type PrometheusConf
- type ProxyCache
- type ProxyCacheConf
- type ProxyRewrite
- type ProxyRewriteConf
- type RealIP
- type RealIPConf
- type Redirect
- type RedirectConf
- type RedirectRegex
- type RedirectRegexConf
- type RegexFilter
- type RequestId
- type RequestIdConf
- type ResponseRewrite
- func (p *ResponseRewrite) Name() string
- func (p *ResponseRewrite) ParseConf(in []byte) (interface{}, error)
- func (p *ResponseRewrite) Priority() int64
- func (p *ResponseRewrite) RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) error
- func (p *ResponseRewrite) Version() string
- type ResponseRewrite2
- type ResponseRewrite2Conf
- type ResponseRewriteConf
- type Say
- type SayConf
- type ServerlessPostFunction
- func (p *ServerlessPostFunction) Name() string
- func (p *ServerlessPostFunction) ParseConf(in []byte) (interface{}, error)
- func (p *ServerlessPostFunction) Priority() int64
- func (p *ServerlessPostFunction) RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) error
- func (p *ServerlessPostFunction) Version() string
- type ServerlessPostFunctionConf
- type ServerlessPreFunction
- func (p *ServerlessPreFunction) Name() string
- func (p *ServerlessPreFunction) ParseConf(in []byte) (interface{}, error)
- func (p *ServerlessPreFunction) Priority() int64
- func (p *ServerlessPreFunction) RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) error
- func (p *ServerlessPreFunction) Version() string
- type ServerlessPreFunctionConf
- type Syslog
- type SyslogConf
Constants ¶
View Source
const ( MatchAllTag = "*" MatchAllForceTag = "**" )
View Source
const (
AuthMethod_Client_Secret_Basic = "client_secret_basic"
)
Variables ¶
View Source
var (
ErrConfConvert = fmt.Errorf("convert to conf err")
)
Functions ¶
This section is empty.
Types ¶
type BasicAuth ¶
type BasicAuth struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*BasicAuth) RequestFilter ¶
type BasicAuthConf ¶
type BasicAuthConf struct {
Disable bool `json:"disable"`
}
type Cors ¶
type Cors struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Cors) RequestFilter ¶
type CorsConf ¶
type CorsConf struct { Disable bool `json:"disable"` // AllowOrigins 允许跨域访问的 Origin。格式为 scheme://host:port,示例如 https://somedomain.com:8081 // 当 allow_credential 为 false 时, // 可以使用 * 来表示允许所有 Origin 通过。 // 你也可以在启用了 allow_credential 后使用 ** 强制允许所有 Origin 均通过, // 但请注意这样存在安全隐患。 AllowOrigins []string `json:"allow_origins,omitempty"` // AllowMethods 允许跨域访问的 Method,比如:GET,POST 等。 // 当 allow_credential 为 false 时, // 可以使用 * 来表示允许所有 Method 通过。 // 你也可以在启用了 allow_credential 后使用 ** 强制允许所有 Method 都通过, // 但请注意这样存在安全隐患。 AllowMethods []string `json:"allow_methods,omitempty"` // 允许跨域访问的 Method // AllowHeaders 允许跨域访问时请求方携带哪些非 CORS 规范 以外的 Header。 // 当 allow_credential 为 false 时, // 可以使用 * 来表示允许所有 Header 通过。 // 你也可以在启用了 allow_credential 后使用 ** 强制允许所有 Header 都通过, // 但请注意这样存在安全隐患。 AllowHeaders []string `json:"allow_headers,omitempty"` // ExposeHeaders 允许跨域访问时响应方携带哪些非 CORS 规范 以外的 Header。 // 当 allow_credential 为 false 时, // 可以使用 * 来表示允许任意 Header 。 // 你也可以在启用了 allow_credential 后使用 ** 强制允许任意 Header, // 但请注意这样存在安全隐患。 ExposeHeaders []string `json:"expose_headers,omitempty"` // MaxAge 浏览器缓存 CORS 结果的最大时间,单位为秒。 // 在这个时间范围内,浏览器会复用上一次的检查结果,-1 表示不缓存。 // 请注意各个浏览器允许的最大时间不同 MaxAge uint64 `json:"max_age,omitempty" default:"5"` // AllowCredential 是否允许跨域访问的请求方携带凭据(如 Cookie 等)。 // 根据 CORS 规范,如果设置该选项为 true, // 那么将不能在其他属性中使用 *。 AllowCredential bool `json:"allow_credential,omitempty"` // AllowOriginsByRegex 使用正则表达式数组来匹配允许跨域访问的 Origin, // 如 [".*\.test.com"] 可以匹配任何 test.com 的子域名 *。 AllowOriginsByRegex []string `json:"allow_origins_by_regex,omitempty"` // AllowOriginsByMetadata 通过引用插件元数据的 allow_origins 配置允许跨域访问的 Origin。 // 比如当插件元数据为 "allow_origins": {"EXAMPLE": "https://example.com"} 时, // 配置 ["EXAMPLE"] 将允许 Origin https://example.com 的访问。 AllowOriginsByMetadata []string `json:"allow_origins_by_metadata,omitempty"` }
type GelfUdpLogger ¶
type GelfUdpLogger struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*GelfUdpLogger) Name ¶
func (p *GelfUdpLogger) Name() string
func (*GelfUdpLogger) ParseConf ¶
func (p *GelfUdpLogger) ParseConf(in []byte) (interface{}, error)
func (*GelfUdpLogger) Priority ¶
func (p *GelfUdpLogger) Priority() int64
func (*GelfUdpLogger) RequestFilter ¶
func (*GelfUdpLogger) Version ¶
func (p *GelfUdpLogger) Version() string
type GelfUdpLoggerConf ¶
type GelfUdpLoggerConf struct { Disable bool `json:"disable"` Host string `json:"host"` Port uint64 `json:"port"` Timeout uint64 `json:"timeout"` LoggerName string `json:"name"` InactiveTimeout uint64 `json:"inactive_timeout"` BufferDuration uint64 `json:"buffer_duration"` MaxRetryCount uint64 `json:"max_retry_count"` RetryDelay uint64 `json:"retry_delay"` IncludeReqBody bool `json:"include_req_body"` BatchMaxSize uint64 `json:"batch_max_size"` }
type Gzip ¶
type Gzip struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Gzip) ResponseFilter ¶
type GzipConf ¶
type GzipConf struct { Disable bool `json:"disable"` HeaderName string `json:"header_name,omitempty" default:"X-Request-Id"` // 唯一请求ID的标头名称 IncludeInResponse bool `json:"include_in_response,omitempty" default:"true"` // true时,在响应头中添加唯一的请求ID。 Algorithm string `json:"algorithm,omitempty" default:"uuid"` // ["uuid", "snowflake", "nanoid"] }
type Headers ¶
type Headers struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Headers) RequestFilter ¶
type HeadersConf ¶
type HttpLogger ¶
type HttpLogger struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*HttpLogger) Name ¶
func (p *HttpLogger) Name() string
func (*HttpLogger) ParseConf ¶
func (p *HttpLogger) ParseConf(in []byte) (interface{}, error)
func (*HttpLogger) Priority ¶
func (p *HttpLogger) Priority() int64
func (*HttpLogger) RequestFilter ¶
func (*HttpLogger) Version ¶
func (p *HttpLogger) Version() string
type HttpLoggerConf ¶
type HttpLoggerConf struct { Disable bool `json:"disable"` URI string `json:"uri"` AuthHeader string `json:"auth_header"` Timeout uint64 `json:"timeout"` LoggerName string `json:"name"` BatchMaxSize uint64 `json:"batch_max_size"` InactiveTimeout uint64 `json:"inactive_timeout"` BufferDuration uint64 `json:"buffer_duration"` MaxRetryCount uint64 `json:"max_retry_count"` RetryDelay uint64 `json:"retry_delay"` IncludeReqBody bool `json:"include_req_body"` ConcatMethod string `json:"concat_method"` }
type IpRestriction ¶
type IpRestriction struct { plugins.DefaultPlugin // contains filtered or unexported fields }
IpRestriction ...
func (*IpRestriction) Name ¶
func (p *IpRestriction) Name() string
func (*IpRestriction) ParseConf ¶
func (p *IpRestriction) ParseConf(in []byte) (interface{}, error)
func (*IpRestriction) Priority ¶
func (p *IpRestriction) Priority() int64
func (*IpRestriction) RequestFilter ¶
func (*IpRestriction) Version ¶
func (p *IpRestriction) Version() string
type IpRestrictionConf ¶
type IpRestrictionConf struct { Disable bool `json:"disable"` // Whitelist 加入白名单的 IP 地址或 CIDR 范围。 Whitelist []string `json:"whitelist,omitempty"` // 加入黑名单的 IP 地址或 CIDR 范围。 Blacklist []string `json:"blacklist,omitempty"` // Message 不允许访问IP地址时返回的消息[1, 1024] Message string `json:"message,omitempty"` // contains filtered or unexported fields }
type JwtAuth ¶
type JwtAuth struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*JwtAuth) RequestFilter ¶
type JwtAuthConf ¶
type LimitReq ¶
type LimitReq struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*LimitReq) ParseConf ¶
ParseConf is called when the configuration is changed. And its output is unique per route.
func (*LimitReq) RequestFilter ¶
RequestFilter is called when a request hits the route
type LimitReqConf ¶
type MultiResponseRewrite ¶
type MultiResponseRewrite struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*MultiResponseRewrite) Name ¶
func (p *MultiResponseRewrite) Name() string
func (*MultiResponseRewrite) ParseConf ¶
func (p *MultiResponseRewrite) ParseConf(in []byte) (interface{}, error)
func (*MultiResponseRewrite) Priority ¶
func (p *MultiResponseRewrite) Priority() int64
func (*MultiResponseRewrite) RequestFilter ¶
func (*MultiResponseRewrite) Version ¶
func (p *MultiResponseRewrite) Version() string
type MultiResponseRewriteConf ¶
type MultiResponseRewriteConf struct { Disable bool `json:"disable"` Variants []PluginMultiResponseRewriteVariantType `json:"variants"` }
type OAuth2 ¶
type OAuth2 struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*OAuth2) RequestFilter ¶
type OAuth2Conf ¶
type OAuth2Conf struct { Disable bool `json:"disable"` ClientId string `json:"client_id,omitempty" comment:"客户端Id"` ClientSecret string `json:"client_secret,omitempty" comment:"客户端secret"` Discovery string `json:"discovery,omitempty" comment:"身份服务器的发现端点的 URL"` Real string `json:"real,omitempty" comment:"用于认证的领域; 默认为apisix"` BearerOnly bool `` /* 127-byte string literal not displayed */ LogoutPath string `json:"logout_path,omitempty" comment:"默认是/logout"` RedirectUri string `json:"redirect_uri,omitempty"` Timeout int `json:"timeout,omitempty" comment:"默认是 3 秒"` SslVerify bool `json:"ssl_verify,omitempty" comment:"默认是 false"` IntrospectionEndpoint string `json:"introspection_endpoint,omitempty" comment:"身份服务器的令牌验证端点的 URL"` // token会直接拼接在连接的后面 IntrospectionEndpointAuthMethod string `json:"introspection_endpoint_auth_method,omitempty" comment:"令牌自省的认证方法名称,如:client_secret_basic"` PublicKey string `json:"public_key,omitempty" comment:"验证令牌的公钥"` TokenSigningAlgValuesExpected string `json:"token_signing_alg_values_expected,omitempty" comment:"用于对令牌进行签名的算法"` }
type PluginHeadersSTSType ¶
type Prometheus ¶
type Prometheus struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Prometheus) Name ¶
func (p *Prometheus) Name() string
func (*Prometheus) ParseConf ¶
func (p *Prometheus) ParseConf(in []byte) (interface{}, error)
func (*Prometheus) Priority ¶
func (p *Prometheus) Priority() int64
func (*Prometheus) RequestFilter ¶
func (*Prometheus) Version ¶
func (p *Prometheus) Version() string
type PrometheusConf ¶
type ProxyCache ¶
type ProxyCache struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ProxyCache) Name ¶
func (p *ProxyCache) Name() string
func (*ProxyCache) ParseConf ¶
func (p *ProxyCache) ParseConf(in []byte) (interface{}, error)
func (*ProxyCache) Priority ¶
func (p *ProxyCache) Priority() int64
func (*ProxyCache) RequestFilter ¶
func (*ProxyCache) Version ¶
func (p *ProxyCache) Version() string
type ProxyCacheConf ¶
type ProxyCacheConf struct { Disable bool `json:"disable"` CacheStrategy string `json:"cache_strategy"` CacheZone string `json:"cache_zone"` CacheKey []string `json:"cache_key"` CacheBypass []string `json:"cache_bypass"` CacheMethod []string `json:"cache_method"` CacheHTTPStatus []string `json:"cache_http_status"` HideCacheHeaders bool `json:"hide_cache_headers"` CacheControl bool `json:"cache_control"` NoCache []string `json:"no_cache"` CacheTTL int `json:"cache_ttl"` }
type ProxyRewrite ¶
type ProxyRewrite struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ProxyRewrite) Name ¶
func (p *ProxyRewrite) Name() string
func (*ProxyRewrite) ParseConf ¶
func (p *ProxyRewrite) ParseConf(in []byte) (interface{}, error)
func (*ProxyRewrite) Priority ¶
func (p *ProxyRewrite) Priority() int64
func (*ProxyRewrite) RequestFilter ¶
func (*ProxyRewrite) Version ¶
func (p *ProxyRewrite) Version() string
type ProxyRewriteConf ¶
type ProxyRewriteConf struct { Disable bool `json:"disable"` Scheme string `json:"scheme,omitempty"` // 协议改写,http/https Method string `json:"method,omitempty"` // 被改写的method Uri string `json:"uri,omitempty"` // url改写 Host string `json:"host,omitempty"` // host进行改写 Headers map[string]string `json:"headers,omitempty"` // 修改的header头,如果value为空时,代表删除该key RegexUri []string `json:"regex_uri,omitempty"` // uri的正则 }
type RealIP ¶
type RealIP struct { plugins.DefaultPlugin // contains filtered or unexported fields }
RealIP 插件用于动态改变传递到 客户端的 IP 地址和端口
func (*RealIP) RequestFilter ¶
type RealIPConf ¶
type RealIPConf struct { Disable bool `json:"disable"` // Source 数据来源,如 arg_realip 或 http_x_forwarded_for, // 动态设置客户端的 IP 地址和端口。 // 如果该值不包含端口,则不会更改客户端的端口。 Source string `json:"source" validate:"required"` // TrustedAddresses IP 或 CIDR 范围列表 // 动态设置 set_real_ip_from 字段 TrustedAddresses []string `json:"trusted_addresses,omitempty"` // Recursive 如果禁用递归搜索,则与受信任地址之一匹配的原始客户端地址将替换为配置的source中发送的最后一个地址。 // 如果启用递归搜索,则与受信任地址之一匹配的原始客户端地址将替换为配置的source中发送的最后一个非受信任地址。 Recursive bool `json:"recursive,omitempty"` }
RealIPConf 和nginx的配置一致
http{ #真实服务器上一级代理的IP地址或者IP段,可以写多行 set_real_ip_from 127.0.0.1; #从哪个header头检索出要的IP地址 real_ip_header X-Forwarded-For; # 递归排除IP地址,ip串从右到左开始排除set_real_ip_from里面出现的IP,如果出现了未出现这些ip段的IP,那么这个IP将被认为是用户的IP real_ip_recursive on; }
type Redirect ¶
type Redirect struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Redirect) RequestFilter ¶
type RedirectConf ¶
type RedirectRegex ¶
type RedirectRegex struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*RedirectRegex) Name ¶
func (p *RedirectRegex) Name() string
func (*RedirectRegex) ParseConf ¶
func (p *RedirectRegex) ParseConf(in []byte) (interface{}, error)
func (*RedirectRegex) Priority ¶
func (p *RedirectRegex) Priority() int64
func (*RedirectRegex) RequestFilter ¶
func (*RedirectRegex) Version ¶
func (p *RedirectRegex) Version() string
type RedirectRegexConf ¶
type RedirectRegexConf struct { Disable bool `json:"disable"` Variants []PluginRedirectRegexVariantType `json:"variants"` }
type RegexFilter ¶
type RequestId ¶
type RequestId struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*RequestId) RequestFilter ¶
type RequestIdConf ¶
type RequestIdConf struct { Disable bool `json:"disable"` HeaderName string `json:"header_name,omitempty" default:"X-Request-Id"` // 唯一请求ID的标头名称 IncludeInResponse bool `json:"include_in_response,omitempty" default:"true"` // true时,在响应头中添加唯一的请求ID。 Algorithm string `json:"algorithm,omitempty" default:"uuid"` // ["uuid", "snowflake", "nanoid"] }
type ResponseRewrite ¶
type ResponseRewrite struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ResponseRewrite) Name ¶
func (p *ResponseRewrite) Name() string
func (*ResponseRewrite) ParseConf ¶
func (p *ResponseRewrite) ParseConf(in []byte) (interface{}, error)
func (*ResponseRewrite) Priority ¶
func (p *ResponseRewrite) Priority() int64
func (*ResponseRewrite) RequestFilter ¶
func (*ResponseRewrite) Version ¶
func (p *ResponseRewrite) Version() string
type ResponseRewrite2 ¶
type ResponseRewrite2 struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ResponseRewrite2) Name ¶
func (p *ResponseRewrite2) Name() string
func (*ResponseRewrite2) ParseConf ¶
func (p *ResponseRewrite2) ParseConf(in []byte) (interface{}, error)
func (*ResponseRewrite2) Priority ¶
func (p *ResponseRewrite2) Priority() int64
func (*ResponseRewrite2) ResponseFilter ¶
func (p *ResponseRewrite2) ResponseFilter(conf interface{}, w *fasthttp.Response) (err error)
func (*ResponseRewrite2) Version ¶
func (p *ResponseRewrite2) Version() string
type ResponseRewrite2Conf ¶
type ResponseRewriteConf ¶
type Say ¶
type Say struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Say) ResponseFilter ¶
type ServerlessPostFunction ¶
type ServerlessPostFunction struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ServerlessPostFunction) Name ¶
func (p *ServerlessPostFunction) Name() string
func (*ServerlessPostFunction) ParseConf ¶
func (p *ServerlessPostFunction) ParseConf(in []byte) (interface{}, error)
func (*ServerlessPostFunction) Priority ¶
func (p *ServerlessPostFunction) Priority() int64
func (*ServerlessPostFunction) RequestFilter ¶
func (*ServerlessPostFunction) Version ¶
func (p *ServerlessPostFunction) Version() string
type ServerlessPreFunction ¶
type ServerlessPreFunction struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*ServerlessPreFunction) Name ¶
func (p *ServerlessPreFunction) Name() string
func (*ServerlessPreFunction) ParseConf ¶
func (p *ServerlessPreFunction) ParseConf(in []byte) (interface{}, error)
func (*ServerlessPreFunction) Priority ¶
func (p *ServerlessPreFunction) Priority() int64
func (*ServerlessPreFunction) RequestFilter ¶
func (*ServerlessPreFunction) Version ¶
func (p *ServerlessPreFunction) Version() string
type Syslog ¶
type Syslog struct { plugins.DefaultPlugin // contains filtered or unexported fields }
func (*Syslog) RequestFilter ¶
Source Files ¶
- basic-auth.go
- cors.go
- gelf-udp-logger.go
- gzip.go
- headers.go
- http-logger.go
- ip-restriction.go
- jwt-auth.go
- limit_req.go
- multi-response-rewrite.go
- oauth2.go
- prometheus.go
- proxy-cache.go
- proxy-rewrite.go
- real-ip.go
- redirect-regex.go
- redirect.go
- request-id.go
- response-rewrite.go
- response_rewrite2.go
- say.go
- serverless-post-function.go
- serverless-pre-function.go
- syslog.go
Click to show internal directories.
Click to hide internal directories.