Home / Function/ TestPanicWithAbortHandler() — gin Function Reference

TestPanicWithAbortHandler() — gin Function Reference

Architecture documentation for the TestPanicWithAbortHandler() function in recovery_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  9f082763_021d_ff12_c1fb_28b9daaefba4["TestPanicWithAbortHandler()"]
  c9a553a7_05a4_91a7_23b0_924f9f59d021["recovery_test.go"]
  9f082763_021d_ff12_c1fb_28b9daaefba4 -->|defined in| c9a553a7_05a4_91a7_23b0_924f9f59d021
  style 9f082763_021d_ff12_c1fb_28b9daaefba4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

recovery_test.go lines 132–153

func TestPanicWithAbortHandler(t *testing.T) {
	const expectCode = 204

	var buf strings.Builder
	router := New()
	router.Use(RecoveryWithWriter(&buf))
	router.GET("/recovery", func(c *Context) {
		// Start writing response
		c.Header("X-Test", "Value")
		c.Status(expectCode)

		// Panic with ErrAbortHandler which should be treated as broken pipe
		panic(http.ErrAbortHandler)
	})
	// RUN
	w := PerformRequest(router, http.MethodGet, "/recovery")
	// TEST
	assert.Equal(t, expectCode, w.Code)
	out := buf.String()
	assert.Contains(t, out, "net/http: abort Handler")
	assert.NotContains(t, out, "panic recovered")
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestPanicWithAbortHandler() do?
TestPanicWithAbortHandler() is a function in the gin codebase, defined in recovery_test.go.
Where is TestPanicWithAbortHandler() defined?
TestPanicWithAbortHandler() is defined in recovery_test.go at line 132.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free