recover

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

README

Recover

Middleware to recover while panic.

Usage

Import

import "github.com/ngamux/middleware/recover"

Instance With Default Config

recoverMiddleware := recover.New()

Instance With Custom Config

recoverMiddleware := recover.New(recover.Config{
  ErrorHandler: func(rw http.ResponseWriter, r *http.Request, e error) {
		rw.WriteHeader(http.StatusInternalServerError)
		fmt.Fprintln(rw, e)
		log.Println("error:", e)
	},
})

Mount to Ngamux

mux := ngamux.New()
mux.Use(recoverMiddleware)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config ...Config) func(next http.HandlerFunc) http.HandlerFunc

Types

type Config

type Config struct {
	ErrorHandler func(http.ResponseWriter, *http.Request, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL