garm/vendor/github.com/gorilla/handlers
Gabriel Adrian Samfira 3ec6aeace2 Update dependencies
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:20:44 +00:00
..
.editorconfig Update dependencies 2023-12-18 16:20:44 +00:00
.gitignore Update dependencies 2023-12-18 16:20:44 +00:00
canonical.go Update dependencies 2023-12-18 16:20:44 +00:00
compress.go Update dependencies 2023-12-18 16:20:44 +00:00
cors.go Update dependencies 2023-12-18 16:20:44 +00:00
doc.go Vendor packages and add Makefile 2022-06-30 10:20:32 +00:00
handlers.go Update dependencies 2023-12-18 16:20:44 +00:00
LICENSE Update dependencies 2023-12-18 16:20:44 +00:00
logging.go Update dependencies 2023-12-18 16:20:44 +00:00
Makefile Update dependencies 2023-12-18 16:20:44 +00:00
proxy_headers.go Update dependencies 2023-12-18 16:20:44 +00:00
README.md Update dependencies 2023-12-18 16:20:44 +00:00
recovery.go Update dependencies 2023-12-18 16:20:44 +00:00

gorilla/handlers

Testing Codecov GoDoc Sourcegraph

Package handlers is a collection of handlers (aka "HTTP middleware") for use with Go's net/http package (or any framework supporting http.Handler), including:

Other handlers are documented on the Gorilla website.

Example

A simple example using handlers.LoggingHandler and handlers.CompressHandler:

import (
    "net/http"
    "github.com/gorilla/handlers"
)

func main() {
    r := http.NewServeMux()

    // Only log requests to our admin dashboard to stdout
    r.Handle("/admin", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard)))
    r.HandleFunc("/", ShowIndex)

    // Wrap our server with our gzip handler to gzip compress all responses.
    http.ListenAndServe(":8000", handlers.CompressHandler(r))
}

License

BSD licensed. See the included LICENSE file for details.