Home / Function/ TestMiddlewareNoMethodDisabled() — gin Function Reference

TestMiddlewareNoMethodDisabled() — gin Function Reference

Architecture documentation for the TestMiddlewareNoMethodDisabled() function in middleware_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

middleware_test.go lines 118–157

func TestMiddlewareNoMethodDisabled(t *testing.T) {
	signature := ""
	router := New()

	// NoMethod disabled
	router.HandleMethodNotAllowed = false

	router.Use(func(c *Context) {
		signature += "A"
		c.Next()
		signature += "B"
	})
	router.Use(func(c *Context) {
		signature += "C"
		c.Next()
		signature += "D"
	})
	router.NoMethod(func(c *Context) {
		signature += "E"
		c.Next()
		signature += "F"
	}, func(c *Context) {
		signature += "G"
		c.Next()
		signature += "H"
	})
	router.NoRoute(func(c *Context) {
		signature += " X "
	})
	router.POST("/", func(c *Context) {
		signature += " XX "
	})

	// RUN
	w := PerformRequest(router, http.MethodGet, "/")

	// TEST
	assert.Equal(t, http.StatusNotFound, w.Code)
	assert.Equal(t, "AC X DB", signature)
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free