util

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err added in v1.2.0

func Err(err error, w http.ResponseWriter, req *http.Request)

Err write err to response writer

func IsEventCreateRequest added in v1.2.0

func IsEventCreateRequest(req *http.Request) bool

func IsKubeletGetNodeReq added in v1.5.0

func IsKubeletGetNodeReq(req *http.Request) bool

IsKubeletGetNodeReq judge whether the request is a get node request from kubelet

func IsKubeletLeaseReq added in v1.2.0

func IsKubeletLeaseReq(req *http.Request) bool

IsKubeletLeaseReq judge whether the request is a lease request from kubelet

func IsListRequestWithNameFieldSelector added in v1.2.0

func IsListRequestWithNameFieldSelector(req *http.Request) bool

IsListRequestWithNameFieldSelector will check if the request has FieldSelector "metadata.name". If found, return true, otherwise false.

func IsPoolScopedResourceListWatchRequest added in v1.5.0

func IsPoolScopedResourceListWatchRequest(req *http.Request) bool

func IsSubjectAccessReviewCreateGetRequest added in v1.2.0

func IsSubjectAccessReviewCreateGetRequest(req *http.Request) bool

func ReListWatchReq added in v1.2.1

func ReListWatchReq(rw http.ResponseWriter, req *http.Request)

func WithCacheHeaderCheck

func WithCacheHeaderCheck(handler http.Handler) http.Handler

WithCacheHeaderCheck add cache agent for response cache in default mode, only kubelet, kube-proxy, flanneld, coredns User-Agent can be supported to cache response. and with Edge-Cache header is also supported.

func WithIfPoolScopedResource added in v1.2.0

func WithIfPoolScopedResource(handler http.Handler) http.Handler

func WithListRequestSelector

func WithListRequestSelector(handler http.Handler) http.Handler

WithListRequestSelector add label selector and field selector string in list request context.

func WithMaxInFlightLimit

func WithMaxInFlightLimit(handler http.Handler, limit int) http.Handler

WithMaxInFlightLimit limits the number of in-flight requests. and when in flight requests exceeds the threshold, the following incoming requests will be rejected.

func WithRequestClientComponent

func WithRequestClientComponent(handler http.Handler, mode util.WorkingMode) http.Handler

WithRequestClientComponent add component field in request context. component is extracted from User-Agent Header, and only the content before the "/" when User-Agent include "/".

func WithRequestContentType

func WithRequestContentType(handler http.Handler) http.Handler

WithRequestContentType add req-content-type in request context. if no Accept header is set, the request will be reject with a message.

func WithRequestTimeout

func WithRequestTimeout(handler http.Handler) http.Handler

func WithRequestTrace

func WithRequestTrace(handler http.Handler) http.Handler

WithRequestTrace used to trace status code and latency for outward requests redirected from proxyserver to apiserver

func WithRequestTraceFull added in v1.0.0

func WithRequestTraceFull(handler http.Handler) http.Handler

WithRequestTraceFull used to trace the entire duration: coming to yurthub -> yurthub to apiserver -> leaving yurthub

func WithSaTokenSubstitute added in v0.7.0

func WithSaTokenSubstitute(handler http.Handler, tenantMgr tenant.Interface) http.Handler

func WriteObject added in v1.2.0

func WriteObject(statusCode int, obj runtime.Object, w http.ResponseWriter, req *http.Request) error

WriteObject write object to response writer

Types

type RemoteProxy added in v1.2.0

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

RemoteProxy is an reverse proxy for remote server

func NewRemoteProxy added in v1.2.0

func NewRemoteProxy(remoteServer *url.URL,
	modifyResponse func(*http.Response) error,
	errhandler func(http.ResponseWriter, *http.Request, error),
	transportMgr transport.Interface,
	stopCh <-chan struct{}) (*RemoteProxy, error)

NewRemoteProxy creates an *RemoteProxy object, and will be used by LoadBalancer

func (*RemoteProxy) Name added in v1.2.0

func (rp *RemoteProxy) Name() string

Name represents the address of remote server

func (*RemoteProxy) RemoteServer added in v1.2.0

func (rp *RemoteProxy) RemoteServer() *url.URL

func (*RemoteProxy) RoundTrip added in v1.2.0

func (rp *RemoteProxy) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is used to implement http.RoundTripper for RemoteProxy.

func (*RemoteProxy) ServeHTTP added in v1.2.0

func (rp *RemoteProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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