{"id":46064441,"url":"https://github.com/gowww/fatal","last_synced_at":"2026-03-01T12:05:44.601Z","repository":{"id":57505758,"uuid":"93346493","full_name":"gowww/fatal","owner":"gowww","description":"🚑 A handler that recovers from panics","archived":false,"fork":false,"pushed_at":"2026-01-27T18:25:55.000Z","size":11,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-28T04:53:01.251Z","etag":null,"topics":["fatal","go","golang","handler","http","middleware","panic","recover"],"latest_commit_sha":null,"homepage":"","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/gowww.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}},"created_at":"2017-06-04T22:58:20.000Z","updated_at":"2026-01-27T18:27:06.000Z","dependencies_parsed_at":"2022-09-26T17:51:47.229Z","dependency_job_id":null,"html_url":"https://github.com/gowww/fatal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gowww/fatal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowww%2Ffatal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowww%2Ffatal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowww%2Ffatal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowww%2Ffatal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gowww","download_url":"https://codeload.github.com/gowww/fatal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowww%2Ffatal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29969243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T11:43:06.159Z","status":"ssl_error","status_checked_at":"2026-03-01T11:43:03.887Z","response_time":124,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["fatal","go","golang","handler","http","middleware","panic","recover"],"created_at":"2026-03-01T12:05:44.073Z","updated_at":"2026-03-01T12:05:44.595Z","avatar_url":"https://github.com/gowww.png","language":"Go","readme":"# [![gowww](https://avatars.githubusercontent.com/u/18078923?s=20)](https://github.com/gowww) fatal [![GoDoc](https://godoc.org/github.com/gowww/fatal?status.svg)](https://godoc.org/github.com/gowww/fatal) [![Build](https://travis-ci.org/gowww/fatal.svg?branch=master)](https://travis-ci.org/gowww/fatal) [![Coverage](https://coveralls.io/repos/github/gowww/fatal/badge.svg?branch=master)](https://coveralls.io/github/gowww/fatal?branch=master) [![Go Report](https://goreportcard.com/badge/github.com/gowww/fatal)](https://goreportcard.com/report/github.com/gowww/fatal) ![Status Stable](https://img.shields.io/badge/status-stable-brightgreen.svg)\n\nPackage [fatal](https://godoc.org/github.com/gowww/fatal) provides a handler that recovers from panics.\n\n## Installing\n\n1. Get package:\n\n\t```Shell\n\tgo get -u github.com/gowww/fatal\n\t```\n\n2. Import it in your code:\n\n\t```Go\n\timport \"github.com/gowww/fatal\"\n\t```\n\n## Usage\n\nTo wrap an [http.Handler](https://golang.org/pkg/net/http/#Handler), use [Handle](https://godoc.org/github.com/gowww/fatal#Handle):\n\n```Go\nmux := http.NewServeMux()\n\nmux.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tpanic(\"error\")\n})\n\nhttp.ListenAndServe(\":8080\", fatal.Handle(mux, nil))\n```\n\nTo wrap an [http.HandlerFunc](https://golang.org/pkg/net/http/#HandlerFunc), use [HandleFunc](https://godoc.org/github.com/gowww/fatal#HandleFunc):\n\n```Go\nhttp.Handle(\"/\", fatal.HandleFunc(func(w http.ResponseWriter, r *http.Request) {\n\tpanic(\"error\")\n}, nil))\n\nhttp.ListenAndServe(\":8080\", nil)\n```\n\n### Custom \"error\" handler\n\nWhen your code panics, the response status is set to 500 and an empty body is sent by default.\n\nBut you can set your own error handler and retrive the error value with [Error](https://godoc.org/github.com/gowww/fatal#Error).  \nIn this case, it's up to you to set the response status code (normally 500):\n\n```Go\nhttp.ListenAndServe(\":8080\", fatal.Handle(mux, \u0026fatal.Options{\n\tRecoverHandler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintf(w, \"error: %v\", fatal.Error(r))\n\t}),\n}))\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgowww%2Ffatal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgowww%2Ffatal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgowww%2Ffatal/lists"}