mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix bug in Wrap (#15302)
Whilst doing other work I have noticed that there is an issue with Wrap when passing an http.Handler - the next should be the next handler in line not empty. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		@@ -68,10 +68,11 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			case func(http.Handler) http.Handler:
 | 
								case func(http.Handler) http.Handler:
 | 
				
			||||||
				var next = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
 | 
									var next = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
 | 
				
			||||||
				t(next).ServeHTTP(resp, req)
 | 
									if len(handlers) > i+1 {
 | 
				
			||||||
				if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 {
 | 
										next = Wrap(handlers[i+1:]...)
 | 
				
			||||||
					return
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									t(next).ServeHTTP(resp, req)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				panic(fmt.Sprintf("Unsupported handler type: %#v", t))
 | 
									panic(fmt.Sprintf("Unsupported handler type: %#v", t))
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user