webapp

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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