wrapper

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestHost

func GetRequestHost() string

func GetRequestMethod

func GetRequestMethod() string

func GetRequestPath

func GetRequestPath() string

func GetRequestScheme

func GetRequestScheme() string

func HttpCall

func HttpCall(cluster Cluster, method, path string, headers [][2]string, body []byte,
	callback ResponseCallback, timeoutMillisecond ...uint32) error

func SetCtx

func SetCtx[PluginConfig any](pluginName string, setFuncs ...SetPluginFunc[PluginConfig])

Types

type Cluster

type Cluster interface {
	ClusterName() string
	HostName() string
}

type ClusterClient

type ClusterClient[C Cluster] struct {
	// contains filtered or unexported fields
}

func NewClusterClient

func NewClusterClient[C Cluster](cluster C) *ClusterClient[C]

func (ClusterClient[C]) Connect

func (c ClusterClient[C]) Connect(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Delete

func (c ClusterClient[C]) Delete(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Get

func (c ClusterClient[C]) Get(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Head

func (c ClusterClient[C]) Head(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Options

func (c ClusterClient[C]) Options(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Patch

func (c ClusterClient[C]) Patch(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Post

func (c ClusterClient[C]) Post(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Put

func (c ClusterClient[C]) Put(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

func (ClusterClient[C]) Trace

func (c ClusterClient[C]) Trace(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error

type CommonHttpCtx

type CommonHttpCtx[PluginConfig any] struct {
	types.DefaultHttpContext
	// contains filtered or unexported fields
}

func (*CommonHttpCtx[PluginConfig]) OnHttpRequestBody

func (ctx *CommonHttpCtx[PluginConfig]) OnHttpRequestBody(bodySize int, endOfStream bool) types.Action

func (*CommonHttpCtx[PluginConfig]) OnHttpRequestHeaders

func (ctx *CommonHttpCtx[PluginConfig]) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action

func (*CommonHttpCtx[PluginConfig]) OnHttpResponseBody

func (ctx *CommonHttpCtx[PluginConfig]) OnHttpResponseBody(bodySize int, endOfStream bool) types.Action

func (*CommonHttpCtx[PluginConfig]) OnHttpResponseHeaders

func (ctx *CommonHttpCtx[PluginConfig]) OnHttpResponseHeaders(numHeaders int, endOfStream bool) types.Action

type CommonPluginCtx

type CommonPluginCtx[PluginConfig any] struct {
	types.DefaultPluginContext
	matcher.RuleMatcher[PluginConfig]
	// contains filtered or unexported fields
}

func (*CommonPluginCtx[PluginConfig]) NewHttpContext

func (ctx *CommonPluginCtx[PluginConfig]) NewHttpContext(contextID uint32) types.HttpContext

func (*CommonPluginCtx[PluginConfig]) OnPluginStart

func (ctx *CommonPluginCtx[PluginConfig]) OnPluginStart(int) types.OnPluginStartStatus

type CommonVmCtx

type CommonVmCtx[PluginConfig any] struct {
	types.DefaultVMContext
	// contains filtered or unexported fields
}

func NewCommonVmCtx

func NewCommonVmCtx[PluginConfig any](pluginName string, setFuncs ...SetPluginFunc[PluginConfig]) *CommonVmCtx[PluginConfig]

func (*CommonVmCtx[PluginConfig]) NewPluginContext

func (ctx *CommonVmCtx[PluginConfig]) NewPluginContext(uint32) types.PluginContext

type DnsCluster

type DnsCluster struct {
	ServiceName string
	Domain      string
	Port        int64
}

func (DnsCluster) ClusterName

func (c DnsCluster) ClusterName() string

func (DnsCluster) HostName

func (c DnsCluster) HostName() string

type HttpClient

type HttpClient interface {
	Get(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Head(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Options(path string, headers [][2]string, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Post(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Put(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Patch(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Delete(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Connect(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
	Trace(path string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
}

type K8sCluster

type K8sCluster struct {
	ServiceName string
	Namespace   string
	Port        int64
	Version     string
	Host        string
}

func (K8sCluster) ClusterName

func (c K8sCluster) ClusterName() string

func (K8sCluster) HostName

func (c K8sCluster) HostName() string

type LogLevel

type LogLevel uint32
const (
	LogLevelTrace LogLevel = iota
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelCritical
)

type LogWrapper

type LogWrapper struct {
	// contains filtered or unexported fields
}

func (LogWrapper) Critical

func (l LogWrapper) Critical(msg string)

func (LogWrapper) Criticalf

func (l LogWrapper) Criticalf(format string, args ...interface{})

func (LogWrapper) Debug

func (l LogWrapper) Debug(msg string)

func (LogWrapper) Debugf

func (l LogWrapper) Debugf(format string, args ...interface{})

func (LogWrapper) Error

func (l LogWrapper) Error(msg string)

func (LogWrapper) Errorf

func (l LogWrapper) Errorf(format string, args ...interface{})

func (LogWrapper) Info

func (l LogWrapper) Info(msg string)

func (LogWrapper) Infof

func (l LogWrapper) Infof(format string, args ...interface{})

func (LogWrapper) Trace

func (l LogWrapper) Trace(msg string)

func (LogWrapper) Tracef

func (l LogWrapper) Tracef(format string, args ...interface{})

func (LogWrapper) Warn

func (l LogWrapper) Warn(msg string)

func (LogWrapper) Warnf

func (l LogWrapper) Warnf(format string, args ...interface{})

type NacosCluster

type NacosCluster struct {
	ServiceName string
	// use DEFAULT-GROUP by default
	Group       string
	NamespaceID string
	Port        int64
	// set true if use edas/sae registry
	IsExtRegistry bool
	Version       string
	Host          string
}

func (NacosCluster) ClusterName

func (c NacosCluster) ClusterName() string

func (NacosCluster) HostName

func (c NacosCluster) HostName() string

type ParseConfigFunc

type ParseConfigFunc[PluginConfig any] func(json gjson.Result, config *PluginConfig, log LogWrapper) error

type ResponseCallback

type ResponseCallback func(statusCode int, responseHeaders http.Header, responseBody []byte)

type SetPluginFunc

type SetPluginFunc[PluginConfig any] func(*CommonVmCtx[PluginConfig])

func ParseConfigBy

func ParseConfigBy[PluginConfig any](f ParseConfigFunc[PluginConfig]) SetPluginFunc[PluginConfig]

func ProcessRequestBodyBy

func ProcessRequestBodyBy[PluginConfig any](f onHttpBodyFunc[PluginConfig]) SetPluginFunc[PluginConfig]

func ProcessRequestHeadersBy

func ProcessRequestHeadersBy[PluginConfig any](f onHttpHeadersFunc[PluginConfig]) SetPluginFunc[PluginConfig]

func ProcessResponseBodyBy

func ProcessResponseBodyBy[PluginConfig any](f onHttpBodyFunc[PluginConfig]) SetPluginFunc[PluginConfig]

func ProcessResponseHeadersBy

func ProcessResponseHeadersBy[PluginConfig any](f onHttpHeadersFunc[PluginConfig]) SetPluginFunc[PluginConfig]

type StaticIpCluster

type StaticIpCluster struct {
	ServiceName string
	Port        int64
	Host        string
}

func (StaticIpCluster) ClusterName

func (c StaticIpCluster) ClusterName() string

func (StaticIpCluster) HostName

func (c StaticIpCluster) HostName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL