http

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 13 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LastHeaderValue

func LastHeaderValue(header http.Header, key string) string

LastHeaderValue gets the last value associated with the given key. It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. If there are no values associated with the key, Get returns "".

Types

type RequestLogHandler added in v0.6.0

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

RequestLogHandler implements an http.Handler that writes request logs and calls the next handler.

func NewRequestLogHandler added in v0.6.0

func NewRequestLogHandler(h http.Handler, w io.Writer, templateStr string,
	inputGetter RequestLogTemplateInputGetter, enableProbeRequestLog bool) (*RequestLogHandler, error)

NewRequestLogHandler creates an http.Handler that logs request logs to an io.Writer.

func (*RequestLogHandler) ServeHTTP added in v0.6.0

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

func (*RequestLogHandler) SetTemplate added in v0.6.0

func (h *RequestLogHandler) SetTemplate(templateStr string) error

SetTemplate sets the template to use for formatting request logs. Setting the template to an empty string turns of writing request logs.

type RequestLogResponse added in v0.6.0

type RequestLogResponse struct {
	Code    int
	Size    int
	Latency float64
}

RequestLogResponse provided response related information for the template execution.

type RequestLogRevision added in v0.6.0

type RequestLogRevision struct {
	Name          string
	Namespace     string
	Service       string
	Configuration string
	PodName       string
	PodIP         string
}

RequestLogRevision provides revision related static information for the template execution.

type RequestLogTemplateInput added in v0.6.0

type RequestLogTemplateInput struct {
	Request  *http.Request
	Response *RequestLogResponse
	Revision *RequestLogRevision
}

RequestLogTemplateInput is the wrapper struct that provides all necessary information for the template execution.

type RequestLogTemplateInputGetter added in v0.6.0

type RequestLogTemplateInputGetter func(req *http.Request, resp *RequestLogResponse) *RequestLogTemplateInput

RequestLogTemplateInputGetter defines a function returning the input to pass to a request log writer.

func RequestLogTemplateInputGetterFromRevision added in v0.6.0

func RequestLogTemplateInputGetterFromRevision(rev *RequestLogRevision) RequestLogTemplateInputGetter

RequestLogTemplateInputGetterFromRevision returns a func that forms a template input using a static revision information.

type ResponseRecorder added in v0.5.0

type ResponseRecorder struct {
	ResponseCode int
	ResponseSize int32
	// contains filtered or unexported fields
}

ResponseRecorder is an implementation of http.ResponseWriter and http.Flusher that captures the response code and size.

func NewResponseRecorder added in v0.5.0

func NewResponseRecorder(w http.ResponseWriter, responseCode int) *ResponseRecorder

NewResponseRecorder creates an http.ResponseWriter that captures the response code and size.

func (*ResponseRecorder) Flush added in v0.5.0

func (rr *ResponseRecorder) Flush()

Flush flushes the buffer to the client.

func (*ResponseRecorder) Header added in v0.5.0

func (rr *ResponseRecorder) Header() http.Header

Header returns the header map that will be sent by WriteHeader.

func (*ResponseRecorder) Hijack added in v0.5.0

func (rr *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack calls Hijack() on the wrapped http.ResponseWriter if it implements http.Hijacker interface, which is required for net/http/httputil/reverseproxy to handle connection upgrade/switching protocol. Otherwise returns an error.

func (*ResponseRecorder) Write added in v0.5.0

func (rr *ResponseRecorder) Write(p []byte) (int, error)

Write writes the data to the connection as part of an HTTP reply.

func (*ResponseRecorder) WriteHeader added in v0.5.0

func (rr *ResponseRecorder) WriteHeader(code int)

WriteHeader sends an HTTP response header with the provided status code.

Jump to

Keyboard shortcuts

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