Essential Go HTTP server middleware  Suggest an edit

Recovery Handler to prevent server from crashing

func Recovery(h http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
        defer func() {
            if err := recover(); err != nil {
                // respondInternalServerError
            }
        }()
        h.ServeHTTP(w , r)
    })
}

  ↑ ↓ to navigate     ↵ to select     Esc to close