Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/dre1080/recover

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/dre1080/recover

  • v1.0.3
  • Source
  • Go
  • Socket score

Version published
Created
Source

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. Fiber, Echo, Gin, Goji, etc.).

HTML

Installation

$ go get github.com/dre1080/recovr

Usage

package main

import (
    "log"
    "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

Fiber Example

import (
	"github.com/gofiber/fiber"
	"github.com/gofiber/adaptor"
)

func main() {
    app := fiber.New()
    app.Use(adaptor.HTTPHandler(recovr.New()))
    app.Listen(3000)
}

Gin Example

import "github.com/gin-gonic/gin"

func main() {
    g := gin.Default()
    g.Use(gin.WrapH(recovr.New()))
    g.Run()
}

Echo Example

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

func main() {
    e := echo.New()
    e.Use(echo.WrapHandler(recovr.New()))
    e.Run(":3000")
}

Goji Example

import "github.com/zenazn/goji"

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

Screenshots

  • Logger

Logger

  • JSON

JSON

  • HTML

HTML

FAQs

Package last updated on 27 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc