| 116 | } |
| 117 | |
| 118 | func TestMiddlewareNoMethodDisabled(t *testing.T) { |
| 119 | signature := "" |
| 120 | router := New() |
| 121 | |
| 122 | // NoMethod disabled |
| 123 | router.HandleMethodNotAllowed = false |
| 124 | |
| 125 | router.Use(func(c *Context) { |
| 126 | signature += "A" |
| 127 | c.Next() |
| 128 | signature += "B" |
| 129 | }) |
| 130 | router.Use(func(c *Context) { |
| 131 | signature += "C" |
| 132 | c.Next() |
| 133 | signature += "D" |
| 134 | }) |
| 135 | router.NoMethod(func(c *Context) { |
| 136 | signature += "E" |
| 137 | c.Next() |
| 138 | signature += "F" |
| 139 | }, func(c *Context) { |
| 140 | signature += "G" |
| 141 | c.Next() |
| 142 | signature += "H" |
| 143 | }) |
| 144 | router.NoRoute(func(c *Context) { |
| 145 | signature += " X " |
| 146 | }) |
| 147 | router.POST("/", func(c *Context) { |
| 148 | signature += " XX " |
| 149 | }) |
| 150 | |
| 151 | // RUN |
| 152 | w := PerformRequest(router, http.MethodGet, "/") |
| 153 | |
| 154 | // TEST |
| 155 | assert.Equal(t, http.StatusNotFound, w.Code) |
| 156 | assert.Equal(t, "AC X DB", signature) |
| 157 | } |
| 158 | |
| 159 | func TestMiddlewareAbort(t *testing.T) { |
| 160 | signature := "" |