handler

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

package handler provides some support structs for http.servehttp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressHandler

func CompressHandler(h http.Handler) http.Handler

CompressHandler gzip compresses HTTP responses for clients that support it via the 'Accept-Encoding' header.

func CompressHandlerLevel

func CompressHandlerLevel(h http.Handler, level int) http.Handler

CompressHandlerLevel gzip compresses HTTP responses with specified compression level for clients that support it via the 'Accept-Encoding' header.

The compression level should be gzip.DefaultCompression, gzip.NoCompression, or any integer value between gzip.BestSpeed and gzip.BestCompression inclusive. gzip.DefaultCompression is used in case of invalid compression level.

Types

type ErrHandler

type ErrHandler struct {
	Handler
	logr.Logger
}

func (ErrHandler) ServeHTTP

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

ServeHTTP allows our Handler type to satisfy http.Handler.

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

type StatusError

type StatusError struct {
	Err  error
	Code int
}

func (StatusError) Error

func (se StatusError) Error() string

func (StatusError) StatusCode

func (se StatusError) StatusCode() int

Jump to

Keyboard shortcuts

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