httputil

package
v0.1.5-test Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBodyBytes                      = 750               // Log lines will be < 2KiB
	RequestTracingMaxRequestBodySize  = 1024 * 1024 * 50  // 50KB
	RequestTracingMaxResponseBodySize = 1024 * 1024 * 150 // 150KB
)
View Source
const (
	// Last-Modified: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
	DateHeaderTimestampFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
)
View Source
const (
	RequestIDContextKey contextKey = "request_id"
)

Variables

This section is empty.

Functions

func DebugLoggingMiddleware

func DebugLoggingMiddleware(requestIDHeaderName string, fields logging.Fields) func(next http.Handler) http.Handler

func ETag

func ETag(checksum string) string

func HeaderTimestamp

func HeaderTimestamp(ts time.Time) string

func HostMatches added in v0.48.0

func HostMatches(r *http.Request, hosts []string) bool

func HostOnly

func HostOnly(hostname string) string

func HostSubdomainOf added in v0.48.0

func HostSubdomainOf(r *http.Request, hosts []string) bool

func HostsOnly added in v0.40.0

func HostsOnly(hostname []string) []string

func LoggingMiddleware

func LoggingMiddleware(requestIDHeaderName string, fields logging.Fields, traceRequestHeaders bool) func(next http.Handler) http.Handler

func RequestID

func RequestID(r *http.Request) (*http.Request, string)

func RequestScheme

func RequestScheme(r *http.Request) string

func ServeHealth

func ServeHealth() http.Handler

func ServePPROF

func ServePPROF(pprofPrefix string) http.Handler

func SetHealthHandlerInfo

func SetHealthHandlerInfo(info string)

func TracingMiddleware

func TracingMiddleware(requestIDHeaderName string, fields logging.Fields, traceRequestHeaders bool) func(http.Handler) http.Handler

Types

type CappedBuffer

type CappedBuffer struct {
	SizeBytes int

	Buffer []byte
	// contains filtered or unexported fields
}

func (*CappedBuffer) Write

func (c *CappedBuffer) Write(p []byte) (n int, err error)

type MetricResponseWriter

type MetricResponseWriter struct {
	http.ResponseWriter
	StatusCode int
}

func NewMetricResponseWriter

func NewMetricResponseWriter(w http.ResponseWriter) *MetricResponseWriter

func (*MetricResponseWriter) WriteHeader

func (mrw *MetricResponseWriter) WriteHeader(code int)

type ResponseRecordingWriter

type ResponseRecordingWriter struct {
	StatusCode   int
	ResponseSize int64
	Writer       http.ResponseWriter
}

func (*ResponseRecordingWriter) Header

func (w *ResponseRecordingWriter) Header() http.Header

func (*ResponseRecordingWriter) Write

func (w *ResponseRecordingWriter) Write(data []byte) (int, error)

func (*ResponseRecordingWriter) WriteHeader

func (w *ResponseRecordingWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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