MCPcopy
hub / github.com/gin-gonic/gin / RecoveryWithWriter

Function RecoveryWithWriter

recovery.go:45–50  ·  recovery.go::RecoveryWithWriter

RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.

(out io.Writer, recovery ...RecoveryFunc)

Source from the content-addressed store, hash-verified

43
44// RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
45func RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc {
46 if len(recovery) > 0 {
47 return CustomRecoveryWithWriter(out, recovery[0])
48 }
49 return CustomRecoveryWithWriter(out, defaultHandleRecovery)
50}
51
52// CustomRecoveryWithWriter returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it.
53func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {

Callers 8

TestPanicCleanFunction · 0.85
TestPanicInHandlerFunction · 0.85
TestPanicWithAbortFunction · 0.85
TestPanicWithBrokenPipeFunction · 0.85
RecoveryFunction · 0.85
CustomRecoveryFunction · 0.85

Calls 1

CustomRecoveryWithWriterFunction · 0.85

Tested by 6

TestPanicCleanFunction · 0.68
TestPanicInHandlerFunction · 0.68
TestPanicWithAbortFunction · 0.68
TestPanicWithBrokenPipeFunction · 0.68