Need help with recover?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

dre1080
129 Stars 4 Forks MIT License 15 Commits 0 Opened issues

Description

:collision: Go HTTP middleware that catches any panics and serves a proper error response.

Services available

!
?

Need anything else?

Contributors list

# 499,303
Elixir
Databas...
PHP
CSS
14 commits

recovr

godoc

Recovr is a HTTP middleware that catches any panics and serves a proper error response.

Works with all frameworks that support native http handler (eg. Echo, Goji, etc.).

HTML

Installation

$ go get github.com/dre1080/recovr

Usage

package main

import ( "net/http"

"github.com/dre1080/recovr"

)

var myPanicHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { panic("you should not have a handler that just panics ;)") })

func main() { recovery := recovr.New() app := recovery(myPanicHandler) http.ListenAndServe("0.0.0.0:3000", app) }

Examples

Echo Example

import "github.com/labstack/echo/v4"

func main() { e := echo.New() e.Use(echo.WrapMiddleware(recovr.New())) e.Logger.Fatal(e.Start(":1323")) }

Goji Example

import "github.com/zenazn/goji"

func main() { goji.Use(recovr.New()) goji.Serve() }

Screenshots

  • Logger

Logger

  • JSON

JSON

  • HTML

HTML

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.