httputil

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 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 v0.0.3

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 ParseMonitoringConfig added in v0.0.4

func ParseMonitoringConfig(types string, methods string) MonitoringConfig

ParseMonitoringConfig parse types and methods strings into MonitoringConfig.

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 added in v0.0.3

func WrapWriter(
	responseWriter http.ResponseWriter,
	monitoringConfig MonitoringConfig,
	logWriter logger.LogWriter,
	lastModified bool,
) *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) 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) 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