Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultLoggingMiddleware(requestIDHeaderName string, fields logging.Fields, middlewareLogLevel string, ...) func(next http.Handler) http.Handler
- func ETag(checksum string) string
- func ExtractClientIP(headers http.Header, remoteAddr string) string
- func GetRequestLakeFSClient(r *http.Request) string
- func HeaderTimestamp(ts time.Time) string
- func HostMatches(r *http.Request, hosts []string) bool
- func HostOnly(hostname string) string
- func HostSubdomainOf(r *http.Request, hosts []string) bool
- func HostsOnly(hostname []string) []string
- func IsRequestCanceled(r *http.Request) bool
- func IsSuccessStatusCode(response *http.Response) bool
- func KeepPrivate(w http.ResponseWriter)
- func LoggingMiddleware(requestIDHeaderName string, fields logging.Fields, ...) func(next http.Handler) http.Handler
- func RequestID(r *http.Request) (*http.Request, string)
- func RequestIDFromContext(ctx context.Context) *string
- func RequestScheme(r *http.Request) string
- func ServeHealth() http.Handler
- func ServePPROF(pprofPrefix string) http.Handler
- func SetClientTrace(ctx context.Context, service string) context.Context
- func SetHealthHandlerInfo(info string)
- func SourceIP(r *http.Request) string
- func StripQuotesAndSpaces(etag string) string
- func TracingMiddleware(requestIDHeaderName string, fields logging.Fields, traceRequestHeaders bool, ...) func(http.Handler) http.Handler
- func WriteAPIError(w http.ResponseWriter, r *http.Request, code int, v interface{})
- func WriteAPIResponse(w http.ResponseWriter, r *http.Request, code int, response interface{})
- type CappedBuffer
- type ErrorResponse
- type MetricResponseWriter
- type Range
- type ResponseRecordingWriter
Constants ¶
const ( RequestIDHeaderName = "X-Request-ID" LoginMailboxHeaderName = "X-LakeFS-Mailbox" )
const ( RequestIDContextKey contextKey = "request_id" AuditLogEndMessage string = "HTTP call ended" )
const ( MaxBodyBytes = 750 // Log lines will be < 2KiB RequestTracingMaxRequestBodySize = 1024 * 1024 * 50 // 50KB RequestTracingMaxResponseBodySize = 1024 * 1024 * 150 // 150KB )
const ( // HttpStatusClientClosedRequest used as internal status code when request context is cancelled HttpStatusClientClosedRequest = 499 // HttpStatusClientClosedRequestText text used for client closed request status code HttpStatusClientClosedRequestText = "Client closed request" )
const (
// DateHeaderTimestampFormat - Last-Modified: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
DateHeaderTimestampFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
)
Variables ¶
var ( ErrBadRange = errors.New("invalid range") ErrUnsatisfiableRange = errors.New("unsatisfiable range") )
var ConcurrentRequests = promauto.NewGaugeVec( prometheus.GaugeOpts{ Name: "lakefs_concurrent_requests", Help: "Number of concurrent requests being processed by lakeFS (API and Gateway)", }, []string{"service", "operation"}, )
Functions ¶
func DefaultLoggingMiddleware ¶ added in v0.68.0
func ExtractClientIP ¶ added in v1.71.0
ExtractClientIP extracts the client IP from the given headers Checks X-Forwarded-For header first (for proxy/load balancer scenarios)
func GetRequestLakeFSClient ¶ added in v0.83.0
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 IsRequestCanceled ¶ added in v0.88.0
func IsSuccessStatusCode ¶ added in v0.113.0
IsSuccessStatusCode returns true for status code 2xx
func KeepPrivate ¶ added in v1.73.0
func KeepPrivate(w http.ResponseWriter)
KeepPrivate sets some headers on response to keep it private: no caching, no sniff, sameorigin, etc. It should be used on any non-API response (HTML, text, object contents, etc.)
func LoggingMiddleware ¶
func RequestIDFromContext ¶ added in v1.40.0
func RequestScheme ¶
func ServeHealth ¶
func ServePPROF ¶
func SetClientTrace ¶ added in v1.28.1
func SetHealthHandlerInfo ¶
func SetHealthHandlerInfo(info string)
func StripQuotesAndSpaces ¶ added in v1.7.0
func TracingMiddleware ¶
func WriteAPIError ¶ added in v1.72.0
func WriteAPIError(w http.ResponseWriter, r *http.Request, code int, v interface{})
WriteAPIError writes an error for a lakeFS API request
func WriteAPIResponse ¶ added in v1.72.0
func WriteAPIResponse(w http.ResponseWriter, r *http.Request, code int, response interface{})
WriteAPIResponse writes a response for lakeFS API request
Types ¶
type CappedBuffer ¶
type ErrorResponse ¶ added in v1.73.0
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse represents an error message response in our API we do not include the generated code for this struct to enable import code without dependence on the generated code
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
Range represents an RFC 2616 HTTP Range
func ParseRange ¶ added in v0.86.0
ParseRange parses an HTTP RFC 2616 Range header value and returns an Range object for the given object length
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)