httputil

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ErrBadRange = errors.New("invalid range")
View Source
var ErrUnsatisfiableRange = errors.New("unsatisfiable range")

Functions

func DefaultLoggingMiddleware added in v0.68.0

func DefaultLoggingMiddleware(requestIDHeaderName string, fields logging.Fields, middlewareLogLevel string, isAdvancedAuth bool) func(next http.Handler) http.Handler

func ETag

func ETag(checksum string) string

func GetRequestLakeFSClient added in v0.83.0

func GetRequestLakeFSClient(r *http.Request) string

GetRequestLakeFSClient get lakeFS client identifier from request.

It extracts the data from X-Lakefs-Client header and fallback to the user-agent

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

func IsRequestCanceled(r *http.Request) bool

func IsSuccessStatusCode added in v0.113.0

func IsSuccessStatusCode(response *http.Response) bool

IsSuccessStatusCode returns true for status code 2xx

func LoggingMiddleware

func LoggingMiddleware(requestIDHeaderName string, fields logging.Fields, loggingMiddlewareLevel string, traceRequestHeaders bool, isAdvancedAuth 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 SetClientTrace added in v1.28.1

func SetClientTrace(ctx context.Context, service string) context.Context

func SetHealthHandlerInfo

func SetHealthHandlerInfo(info string)

func SourceIP added in v0.95.0

func SourceIP(r *http.Request) string

func StripQuotesAndSpaces added in v1.7.0

func StripQuotesAndSpaces(etag string) string

func TracingMiddleware

func TracingMiddleware(requestIDHeaderName string, fields logging.Fields, traceRequestHeaders bool, isAdvancedAuth 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 Range added in v0.86.0

type Range struct {
	StartOffset int64
	EndOffset   int64
}

Range represents an RFC 2616 HTTP Range

func ParseRange added in v0.86.0

func ParseRange(spec string, length int64) (Range, error)

ParseRange parses an HTTP RFC 2616 Range header value and returns an Range object for the given object length

func (Range) Size added in v0.104.0

func (r Range) Size() int64

func (Range) String added in v0.86.0

func (r Range) String() string

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