httputil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httputil a package for handling http data tasks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MonitoringConfig added in v1.1.0

type MonitoringConfig struct {
	Types   []string `json:"types,omitempty" yaml:"types,omitempty" toml:"types,omitempty" export:"true"`
	Methods []string `json:"methods,omitempty" yaml:"methods,omitempty" toml:"methods,omitempty" export:"true"`
}

MonitoringConfig structure of data for handling configuration for controlling what content is monitored.

func (*MonitoringConfig) EnsureDefaults added in v1.1.0

func (config *MonitoringConfig) EnsureDefaults()

EnsureDefaults check Types and Methods for empty arrays and apply default values if found.

func (*MonitoringConfig) EnsureProperFormat added in v1.2.0

func (config *MonitoringConfig) EnsureProperFormat()

EnsureProperFormat handle weird yaml parsing until the underlying issue can be resolved.

type RequestWrapper added in v1.1.0

type RequestWrapper struct {
	http.Request
	// contains filtered or unexported fields
}

RequestWrapper a struct that centralizes request modifications.

func WrapRequest added in v1.1.0

func WrapRequest(request *http.Request, monitoringConfig MonitoringConfig, logWriter logger.LogWriter) *RequestWrapper

WrapRequest to get a new instance of RequestWrapper.

func (*RequestWrapper) CloneNoEncode added in v1.1.0

func (req *RequestWrapper) CloneNoEncode() *http.Request

CloneNoEncode create an http.Request that request no encoding.

func (*RequestWrapper) CloneWithSupportedEncoding added in v1.1.0

func (req *RequestWrapper) CloneWithSupportedEncoding() *http.Request

CloneWithSupportedEncoding create an http.Request that request only supported encoding.

func (*RequestWrapper) GetEncodingTarget added in v1.1.0

func (req *RequestWrapper) GetEncodingTarget() string

GetEncodingTarget get the supported encoding algorithm preferred by request.

func (*RequestWrapper) SupportsProcessing added in v1.1.0

func (req *RequestWrapper) SupportsProcessing() bool

SupportsProcessing determine if http.Request is supported by this plugin.

type ResponseWrapper

type ResponseWrapper struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseWrapper a wrapper used to simplify ResponseWriter data access and manipulation.

func WrapWriter added in v1.1.0

func WrapWriter(
	responseWriter http.ResponseWriter,
	monitoringConfig MonitoringConfig,
	logWriter logger.LogWriter,
	lastModified bool,
) *ResponseWrapper

WrapWriter create a ResponseWrapper for provided configuration.

func (*ResponseWrapper) CloseNotify added in v1.0.0

func (wrapper *ResponseWrapper) CloseNotify() <-chan bool

CloseNotify returns a channel that receives at most a single value (true) when the client connection has gone away.

func (*ResponseWrapper) Flush added in v1.0.0

func (wrapper *ResponseWrapper) Flush()

Flush sends any buffered data to the client.

func (*ResponseWrapper) GetBuffer

func (wrapper *ResponseWrapper) GetBuffer() *bytes.Buffer

GetBuffer get a pointer to the ResponseWriter buffer.

func (*ResponseWrapper) GetContent

func (wrapper *ResponseWrapper) GetContent() ([]byte, error)

GetContent load the content currently in the internal buffer accounting for possible encoding.

func (*ResponseWrapper) Hijack added in v1.0.0

func (wrapper *ResponseWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack hijacks the connection.

func (*ResponseWrapper) LogHeaders added in v0.5.2

func (wrapper *ResponseWrapper) LogHeaders()

LogHeaders writes current response headers.

func (*ResponseWrapper) SetContent

func (wrapper *ResponseWrapper) SetContent(data []byte, encoding string)

SetContent write data to the internal ResponseWriter buffer and match initial encoding.

func (*ResponseWrapper) SetLastModified

func (wrapper *ResponseWrapper) SetLastModified(value bool)

SetLastModified update the local lastModified variable from non-package-based users.

func (*ResponseWrapper) SupportsProcessing

func (wrapper *ResponseWrapper) SupportsProcessing() bool

SupportsProcessing determine if HttpWrapper is supported by this plugin based on encoding.

func (*ResponseWrapper) Write

func (wrapper *ResponseWrapper) Write(data []byte) (int, error)

Write data to internal buffer and mark the status code as http.StatusOK.

func (*ResponseWrapper) WriteHeader

func (wrapper *ResponseWrapper) WriteHeader(statusCode int)

WriteHeader into wrapped ResponseWriter.

Jump to

Keyboard shortcuts

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