proxy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotApplyResponseTransformers = errors.New("cannot apply response transformers")
	ErrCannotCreateRESTClient          = errors.New("cannot create rest client")
	ErrCannotGetProxiedResponseBody    = errors.New("cannot get response of proxied response body")
	ErrCannotParseRequestURI           = errors.New("cannot parse request URI")
	ErrCannotTransformResponseBody     = errors.New("cannot transform response body")
	ErrCannotWriteResponseBody         = errors.New("cannot write body to the response")
	ErrContextIsNil                    = errors.New("context is nil")
	ErrResponseWriterIsNil             = errors.New("response writer is nil")
)

Functions

This section is empty.

Types

type HTTP

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

func NewHTTP

func NewHTTP(restClientFactory kube.RESTClientFactory, responseTransformers []ResponseBodyTransformer) *HTTP

func (*HTTP) DoServeHTTP

func (h *HTTP) DoServeHTTP(ctx context.Context, w http.ResponseWriter, r http.Request) error

DoServeHTTP does the actual job of ServeHTTP, but it returns an error

This method is useful when you want to integrate the handler with a different http server, and it helps to avoid the log.Printf in ServeHTTP, leaving the responsibility of the error handling to the caller.

func (*HTTP) ServeHTTP

func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface

type JqResponseBodyTransformer

type JqResponseBodyTransformer struct{}

func NewJqResponseBodyTransformer

func NewJqResponseBodyTransformer() *JqResponseBodyTransformer

func (*JqResponseBodyTransformer) Name

func (jq *JqResponseBodyTransformer) Name() string

func (*JqResponseBodyTransformer) Run

func (jq *JqResponseBodyTransformer) Run(body []byte, opts map[string]any) ([]byte, error)

type ResponseBodyTransformer

type ResponseBodyTransformer interface {
	Name() string
	Run([]byte, map[string]any) ([]byte, error)
}

Jump to

Keyboard shortcuts

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