{"id":17217574,"url":"https://github.com/lrstanley/recoverer","last_synced_at":"2025-04-13T23:24:04.769Z","repository":{"id":32508647,"uuid":"104472090","full_name":"lrstanley/recoverer","owner":"lrstanley","description":"Simple Go http middleware to catch (and optionally display) panics gracefully","archived":false,"fork":false,"pushed_at":"2025-02-19T02:59:02.000Z","size":77,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T13:40:44.327Z","etag":null,"topics":["go","golang","http","http-middleware"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/lrstanley/recoverer","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lrstanley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"lrstanley"}},"created_at":"2017-09-22T12:30:12.000Z","updated_at":"2025-02-19T02:59:05.000Z","dependencies_parsed_at":"2024-01-25T05:29:06.624Z","dependency_job_id":"b1734d1f-8cc3-4d2e-bbd4-0efd5d6bd90a","html_url":"https://github.com/lrstanley/recoverer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrstanley%2Frecoverer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrstanley%2Frecoverer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrstanley%2Frecoverer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrstanley%2Frecoverer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lrstanley","download_url":"https://codeload.github.com/lrstanley/recoverer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248795189,"owners_count":21162726,"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","http","http-middleware"],"created_at":"2024-10-15T03:44:20.801Z","updated_at":"2025-04-13T23:24:04.740Z","avatar_url":"https://github.com/lrstanley.png","language":"Go","funding_links":["https://github.com/sponsors/lrstanley"],"categories":[],"sub_categories":[],"readme":"\u003c!-- template:define:options\n{\n  \"nodescription\": true\n}\n--\u003e\n![logo](https://liam.sh/-/gh/svg/lrstanley/recoverer?icon=ic%3Abaseline-error\u0026icon.height=80\u0026layout=left\u0026icon.color=rgba%28222%2C+63%2C+65%2C+1%29\u0026bgcolor=rgba%2830%2C+0%2C+0%2C+1%29)\n\n\u003c!-- template:begin:header --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/tags\"\u003e\n    \u003cimg title=\"Latest Semver Tag\" src=\"https://img.shields.io/github/v/tag/lrstanley/recoverer?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/commits/master\"\u003e\n    \u003cimg title=\"Last commit\" src=\"https://img.shields.io/github/last-commit/lrstanley/recoverer?style=flat-square\"\u003e\n  \u003c/a\u003e\n\n\n  \u003ca href=\"https://github.com/lrstanley/recoverer/actions?query=workflow%3Atest+event%3Apush\"\u003e\n    \u003cimg title=\"GitHub Workflow Status (test @ master)\" src=\"https://img.shields.io/github/actions/workflow/status/lrstanley/recoverer/test.yml?branch=master\u0026label=test\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n\n\n  \u003ca href=\"https://codecov.io/gh/lrstanley/recoverer\"\u003e\n    \u003cimg title=\"Code Coverage\" src=\"https://img.shields.io/codecov/c/github/lrstanley/recoverer/master?style=flat-square\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://pkg.go.dev/github.com/lrstanley/recoverer\"\u003e\n    \u003cimg title=\"Go Documentation\" src=\"https://pkg.go.dev/badge/github.com/lrstanley/recoverer?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/lrstanley/recoverer\"\u003e\n    \u003cimg title=\"Go Report Card\" src=\"https://goreportcard.com/badge/github.com/lrstanley/recoverer?style=flat-square\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/issues?q=is:open+is:issue+label:bug\"\u003e\n    \u003cimg title=\"Bug reports\" src=\"https://img.shields.io/github/issues/lrstanley/recoverer/bug?label=issues\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/issues?q=is:open+is:issue+label:enhancement\"\u003e\n    \u003cimg title=\"Feature requests\" src=\"https://img.shields.io/github/issues/lrstanley/recoverer/enhancement?label=feature%20requests\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/pulls\"\u003e\n    \u003cimg title=\"Open Pull Requests\" src=\"https://img.shields.io/github/issues-pr/lrstanley/recoverer?label=prs\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lrstanley/recoverer/discussions/new?category=q-a\"\u003e\n    \u003cimg title=\"Ask a Question\" src=\"https://img.shields.io/badge/support-ask_a_question!-blue?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://liam.sh/chat\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-bytecord-blue.svg?style=flat-square\" title=\"Discord Chat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- template:end:header --\u003e\n\n\u003c!-- template:begin:toc --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n## :link: Table of Contents\n\n  - [Why](#grey_question-why)\n  - [Examples](#examples)\n    - [Using net/http's default ServeMux](#using-nethttps-default-servemux)\n    - [Using go-chi](#using-go-chi)\n  - [Screenshot](#screenshot)\n  - [Support \u0026amp; Assistance](#raising_hand_man-support--assistance)\n  - [Contributing](#handshake-contributing)\n  - [License](#balance_scale-license)\n\u003c!-- template:end:toc --\u003e\n\n## :grey_question: Why\n\nrecoverer is a simple Go http middleware to catch (and optionally display when\ndebugging) panics, and attempt to gracefully recover them. recoverer also has\nthe ability to display such errors (and exported expvar variables) via a clean\nand simple html generated error page (shown below).\n\n## Examples\n\n\u003c!-- template:begin:goget --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n```console\ngo get -u github.com/lrstanley/recoverer@latest\n```\n\u003c!-- template:end:goget --\u003e\n\n### Using net/http's default ServeMux\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/lrstanley/recoverer\"\n)\n\nfunc hello(w http.ResponseWriter, r *http.Request) {\n\tpanic(\"uhoh.. things happened.\")\n\n\tw.Write([]byte(\"Hello World!\n\"))\n}\n\nfunc main() {\n\trec := recoverer.New(recoverer.Options{\n\t\tLogger: os.Stderr, Show: true, Simple: false,\n\t})\n\n\thttp.Handle(\"/\", rec(http.HandlerFunc(hello)))\n\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n### Using go-chi\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/go-chi/chi\"\n\t\"github.com/go-chi/chi/middleware\"\n\t\"github.com/lrstanley/recoverer\"\n)\n\nfunc main() {\n\tr := chi.NewRouter()\n\n\tr.Use(recoverer.New(recoverer.Options{Logger: os.Stderr, Show: true, Simple: false}))\n\tr.Use(middleware.Logger)\n\tr.Use(middleware.DefaultCompress)\n\n\tr.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"Hello World!\n\"))\n\n\t\tpanic(\"uhoh.. things happened.\")\n\t})\n\n    log.Fatal(http.ListenAndServe(\":8080\", r))\n}\n```\n\n## Screenshot\n\n![Example screenshot](https://i.imgur.com/TF0Y7gV.png)\n\n\u003c!-- template:begin:support --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n## :raising_hand_man: Support \u0026 Assistance\n\n* :heart: Please review the [Code of Conduct](.github/CODE_OF_CONDUCT.md) for\n     guidelines on ensuring everyone has the best experience interacting with\n     the community.\n* :raising_hand_man: Take a look at the [support](.github/SUPPORT.md) document on\n     guidelines for tips on how to ask the right questions.\n* :lady_beetle: For all features/bugs/issues/questions/etc, [head over here](https://github.com/lrstanley/recoverer/issues/new/choose).\n\u003c!-- template:end:support --\u003e\n\n\u003c!-- template:begin:contributing --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n## :handshake: Contributing\n\n* :heart: Please review the [Code of Conduct](.github/CODE_OF_CONDUCT.md) for guidelines\n     on ensuring everyone has the best experience interacting with the\n    community.\n* :clipboard: Please review the [contributing](.github/CONTRIBUTING.md) doc for submitting\n     issues/a guide on submitting pull requests and helping out.\n* :old_key: For anything security related, please review this repositories [security policy](https://github.com/lrstanley/recoverer/security/policy).\n\u003c!-- template:end:contributing --\u003e\n\n\u003c!-- template:begin:license --\u003e\n\u003c!-- do not edit anything in this \"template\" block, its auto-generated --\u003e\n## :balance_scale: License\n\n```\nMIT License\n\nCopyright (c) 2017 Liam Stanley \u003cliam@liam.sh\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n_Also located [here](LICENSE)_\n\u003c!-- template:end:license --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrstanley%2Frecoverer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flrstanley%2Frecoverer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrstanley%2Frecoverer/lists"}