optimize retry&failover logic (#1903)

This commit is contained in:
澄潭
2025-03-17 11:19:33 +08:00
committed by GitHub
parent 4a82d50d80
commit 9a89665b22
8 changed files with 104 additions and 125 deletions

View File

@@ -44,6 +44,7 @@ type HttpContext interface {
GetContext(key string) interface{}
GetBoolContext(key string, defaultValue bool) bool
GetStringContext(key, defaultValue string) string
GetByteSliceContext(key string, defaultValue []byte) []byte
GetUserAttribute(key string) interface{}
SetUserAttribute(key string, value interface{})
SetUserAttributeMap(kvmap map[string]interface{})
@@ -483,6 +484,13 @@ func (ctx *CommonHttpCtx[PluginConfig]) GetStringContext(key, defaultValue strin
return defaultValue
}
func (ctx *CommonHttpCtx[PluginConfig]) GetByteSliceContext(key string, defaultValue []byte) []byte {
if s, ok := ctx.userContext[key].([]byte); ok {
return s
}
return defaultValue
}
func (ctx *CommonHttpCtx[PluginConfig]) Scheme() string {
proxywasm.SetEffectiveContext(ctx.contextID)
return GetRequestScheme()