httputils

package
v0.0.0-...-d0f20ad Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorJSON

func ErrorJSON(w io.Writer, err error) error

ErrorJSON writes the given error JSON-formatted to w.

func GetQueryParams

func GetQueryParams(r *http.Request) url.Values

GetQueryParams calls r.ParseForm and returns r.Form.

func RespondJSON

func RespondJSON(w io.Writer, val promql.Value) error

RespondJSON converts the given data value to JSON and writes it to w.

Types

type CompressionHandler

type CompressionHandler struct {
	Handler http.Handler
}

CompressionHandler is a wrapper around http.Handler which adds suitable response compression based on the client's Accept-Encoding headers.

func (CompressionHandler) ServeHTTP

func (c CompressionHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)

ServeHTTP adds compression to the original http.Handler's ServeHTTP() method.

Jump to

Keyboard shortcuts

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