webapp

package
v1.21.12 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeTextCharset = "text/plain; charset=utf-8"
	MimeTypeText        = "text/plain"
	MimeTypeBytes       = "application/octet-stream"
	MimeTypeAll         = "*/*"

	HeaderNameAccept      = "accept"
	HeaderNameContentType = "content-type"
)

Variables

This section is empty.

Functions

func CORSMiddleware added in v1.21.0

func CORSMiddleware(next http.Handler) http.Handler

func GetContentType

func GetContentType(h http.Header, defaultType string) (string, map[string]string, error)

GetContentType returns the content type and parameters from the header. If the content type is not set, the defaultType is returned.

func GetResponseMimeType

func GetResponseMimeType(h http.Header, defaultType string, mimeTypes ...string) (string, error)

GetResponseMimeType returns the response content type based on the Accept header. If the Accept header is not set, the defaultType is returned. If the Accept header is set, the response content type is negotiated based on the mimeTypes.

func MetricsHandler added in v1.14.6

func MetricsHandler(w http.ResponseWriter, _ *http.Request)

MetricsHandler is a HTTP handler that returns metrics from the ForNerds MetricsSet.

func RequestLogger added in v1.20.1

func RequestLogger(h http.Handler) http.Handler

RequestLogger logs the request method and uri to stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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