recovery.go — gin Source File
Architecture documentation for recovery.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b2655a63_5a3e_56ca_c0dd_550d7efec3e6["recovery.go"] 4d187a4e_b459_c18d_d79b_e367af9eb3b7["bufio"] b2655a63_5a3e_56ca_c0dd_550d7efec3e6 --> 4d187a4e_b459_c18d_d79b_e367af9eb3b7 style b2655a63_5a3e_56ca_c0dd_550d7efec3e6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
import (
"bufio"
"bytes"
"cmp"
"errors"
"fmt"
"io"
"log"
"net/http"
"net/http/httputil"
"os"
"runtime"
"strings"
"syscall"
"time"
"github.com/gin-gonic/gin/internal/bytesconv"
)
const (
dunno = "???"
stackSkip = 3
)
// RecoveryFunc defines the function passable to CustomRecovery.
type RecoveryFunc func(c *Context, err any)
// Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
func Recovery() HandlerFunc {
return RecoveryWithWriter(DefaultErrorWriter)
}
// CustomRecovery returns a middleware that recovers from any panics and calls the provided handle func to handle it.
func CustomRecovery(handle RecoveryFunc) HandlerFunc {
return RecoveryWithWriter(DefaultErrorWriter, handle)
}
// RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
func RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc {
if len(recovery) > 0 {
return CustomRecoveryWithWriter(out, recovery[0])
}
return CustomRecoveryWithWriter(out, defaultHandleRecovery)
}
// CustomRecoveryWithWriter returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it.
func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
var logger *log.Logger
if out != nil {
logger = log.New(out, "\n\n\x1b[31m", log.LstdFlags)
}
return func(c *Context) {
defer func() {
if rec := recover(); rec != nil {
// ... (140 more lines)
Domain
Subdomains
Functions
Classes
Types
Dependencies
- bufio
Source
Frequently Asked Questions
What does recovery.go do?
recovery.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Middleware subdomain.
What functions are defined in recovery.go?
recovery.go defines 11 function(s): CustomRecovery, CustomRecoveryWithWriter, Recovery, RecoveryWithWriter, c, defaultHandleRecovery, function, readNthLine, secureRequestDump, stack, and 1 more.
What does recovery.go depend on?
recovery.go imports 1 module(s): bufio.
Where is recovery.go in the architecture?
recovery.go is located at recovery.go (domain: GinCore, subdomain: Middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free