httputil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 11 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

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

func (config *MonitoringConfig) EnsureDefaults()

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

func (*MonitoringConfig) EnsureProperFormat

func (config *MonitoringConfig) EnsureProperFormat()

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

type RequestWrapper

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

RequestWrapper a struct that centralizes request modifications.

func WrapRequest

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

WrapRequest to get a new instance of RequestWrapper.

func (*RequestWrapper) CloneNoEncode

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

CloneNoEncode create an http.Request that request no encoding.

func (*RequestWrapper) CloneWithSupportedEncoding

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

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

func (*RequestWrapper) GetEncodingTarget

func (req *RequestWrapper) GetEncodingTarget() string

GetEncodingTarget get the supported encoding algorithm preferred by request.

func (*RequestWrapper) SupportsProcessing

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

func WrapWriter(
	responseWriter http.ResponseWriter,
	monitoringConfig MonitoringConfig,
	logWriter logger.LogWriter,
	lastModified bool,
	cspPlaceholder *regexp.Regexp,
	generateNonce func() []byte,
) *ResponseWrapper

WrapWriter create a ResponseWrapper for provided configuration.

func (*ResponseWrapper) CloseNotify

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) ContainsCSP

func (wrapper *ResponseWrapper) ContainsCSP() bool

ContainsCSP tells whether or not current response contains CSP related headers.

func (*ResponseWrapper) Flush

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) GetHeader

func (wrapper *ResponseWrapper) GetHeader(headerName string) string

GetHeader returs header value.

func (*ResponseWrapper) Hijack

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

Hijack hijacks the connection.

func (*ResponseWrapper) LogHeaders

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