{"id":13492656,"url":"https://github.com/gorilla/handlers","last_synced_at":"2025-04-23T20:58:32.202Z","repository":{"id":6705878,"uuid":"7951393","full_name":"gorilla/handlers","owner":"gorilla","description":"Package gorilla/handlers is a collection of useful middleware for Go HTTP services \u0026 web applications 🛃","archived":false,"fork":false,"pushed_at":"2024-02-20T16:27:20.000Z","size":174,"stargazers_count":1693,"open_issues_count":23,"forks_count":275,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-04-23T20:58:27.802Z","etag":null,"topics":["go","golang","gorilla","gorilla-web-toolkit","handler","http","middleware"],"latest_commit_sha":null,"homepage":"https://gorilla.github.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gorilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-02-01T03:53:49.000Z","updated_at":"2025-04-23T12:37:46.000Z","dependencies_parsed_at":"2023-10-20T20:04:07.091Z","dependency_job_id":"dd46f289-595a-4ee8-a28f-d51307620fad","html_url":"https://github.com/gorilla/handlers","commit_stats":{"total_commits":140,"total_committers":48,"mean_commits":"2.9166666666666665","dds":0.8071428571428572,"last_synced_commit":"546854cf1d61a016260b224e2526a29ff5b5c5ae"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fhandlers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fhandlers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fhandlers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fhandlers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gorilla","download_url":"https://codeload.github.com/gorilla/handlers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","gorilla","gorilla-web-toolkit","handler","http","middleware"],"created_at":"2024-07-31T19:01:07.946Z","updated_at":"2025-04-23T20:58:32.171Z","avatar_url":"https://github.com/gorilla.png","language":"Go","readme":"# gorilla/handlers\n\n![Testing](https://github.com/gorilla/handlers/actions/workflows/test.yml/badge.svg)\n[![Codecov](https://codecov.io/github/gorilla/handlers/branch/main/graph/badge.svg)](https://codecov.io/github/gorilla/handlers)\n[![GoDoc](https://godoc.org/github.com/gorilla/handlers?status.svg)](https://godoc.org/github.com/gorilla/handlers)\n[![Sourcegraph](https://sourcegraph.com/github.com/gorilla/handlers/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/handlers?badge)\n\nPackage handlers is a collection of handlers (aka \"HTTP middleware\") for use\nwith Go's `net/http` package (or any framework supporting `http.Handler`), including:\n\n* [**LoggingHandler**](https://godoc.org/github.com/gorilla/handlers#LoggingHandler) for logging HTTP requests in the Apache [Common Log\n  Format](http://httpd.apache.org/docs/2.2/logs.html#common).\n* [**CombinedLoggingHandler**](https://godoc.org/github.com/gorilla/handlers#CombinedLoggingHandler) for logging HTTP requests in the Apache [Combined Log\n  Format](http://httpd.apache.org/docs/2.2/logs.html#combined) commonly used by\n  both Apache and nginx.\n* [**CompressHandler**](https://godoc.org/github.com/gorilla/handlers#CompressHandler) for gzipping responses.\n* [**ContentTypeHandler**](https://godoc.org/github.com/gorilla/handlers#ContentTypeHandler) for validating requests against a list of accepted\n  content types.\n* [**MethodHandler**](https://godoc.org/github.com/gorilla/handlers#MethodHandler) for matching HTTP methods against handlers in a\n  `map[string]http.Handler`\n* [**ProxyHeaders**](https://godoc.org/github.com/gorilla/handlers#ProxyHeaders) for populating `r.RemoteAddr` and `r.URL.Scheme` based on the\n  `X-Forwarded-For`, `X-Real-IP`, `X-Forwarded-Proto` and RFC7239 `Forwarded`\n  headers when running a Go server behind a HTTP reverse proxy.\n* [**CanonicalHost**](https://godoc.org/github.com/gorilla/handlers#CanonicalHost) for re-directing to the preferred host when handling multiple \n  domains (i.e. multiple CNAME aliases).\n* [**RecoveryHandler**](https://godoc.org/github.com/gorilla/handlers#RecoveryHandler) for recovering from unexpected panics.\n\nOther handlers are documented [on the Gorilla\nwebsite](https://www.gorillatoolkit.org/pkg/handlers).\n\n## Example\n\nA simple example using `handlers.LoggingHandler` and `handlers.CompressHandler`:\n\n```go\nimport (\n    \"net/http\"\n    \"github.com/gorilla/handlers\"\n)\n\nfunc main() {\n    r := http.NewServeMux()\n\n    // Only log requests to our admin dashboard to stdout\n    r.Handle(\"/admin\", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard)))\n    r.HandleFunc(\"/\", ShowIndex)\n\n    // Wrap our server with our gzip handler to gzip compress all responses.\n    http.ListenAndServe(\":8000\", handlers.CompressHandler(r))\n}\n```\n\n## License\n\nBSD licensed. See the included LICENSE file for details.\n\n","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["中间件","Middleware"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorilla%2Fhandlers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgorilla%2Fhandlers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorilla%2Fhandlers/lists"}