hmiddleware

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACMEValidationMiddleware added in v0.0.4

func ACMEValidationMiddleware(validationURL *url.URL) func(http.Handler) http.Handler

ACMEValidationMiddleware implements the HTTP01 based redirect protocol specific to heroku ACM.

func CORS

func CORS(next http.Handler) http.Handler

CORS adds Cross-Origin Resource Sharing headers to all outgoing requests. This is known as something that is kind of hard to get right. See docs at https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS for more information.

Example
r := chi.NewRouter()
r.Use(CORS)

// OR

var h http.Handler

if err := http.ListenAndServe(":"+os.Getenv("PORT"), CORS(h)); err != nil {
	log.Fatal(err)
}
Output:

func DisableKeepalive

func DisableKeepalive(next http.Handler) http.Handler

DisableKeepalive instructs the Go HTTP stack to close the incoming HTTP connection once all requests processed by this middleware are complete.

Example
r := chi.NewRouter()
r.Use(DisableKeepalive)

// OR

var h http.Handler

if err := http.ListenAndServe(":"+os.Getenv("PORT"), DisableKeepalive(h)); err != nil {
	log.Fatal(err)
}
Output:

func EnsureTLS

func EnsureTLS(next http.Handler) http.Handler

EnsureTLS ensures all incoming requests identify as having been proxied via https from the upstream reverse proxy. The way that this uses to check relies on the `X-Forwarded-Proto` header which is not defined by any formal standard. For more information on this header, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto.

Example
r := chi.NewRouter()
r.Use(EnsureTLS)

// OR

var h http.Handler

if err := http.ListenAndServe(":"+os.Getenv("PORT"), EnsureTLS(h)); err != nil {
	log.Fatal(err)
}
Output:

Types

This section is empty.

Directories

Path Synopsis
Package httpmetrics provides an http.Handler for collecting metrics about http servers.
Package httpmetrics provides an http.Handler for collecting metrics about http servers.

Jump to

Keyboard shortcuts

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