(next http.Handler)
| 168 | } |
| 169 | |
| 170 | func executeRequestSafelyMiddleware(next http.Handler) http.Handler { |
| 171 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 172 | defer func() { |
| 173 | if x := recover(); x != nil { |
| 174 | c := w.(*aeContext) |
| 175 | logf(c, 4, "%s", renderPanic(x)) // 4 == critical |
| 176 | c.outCode = 500 |
| 177 | } |
| 178 | }() |
| 179 | |
| 180 | next.ServeHTTP(w, r) |
| 181 | }) |
| 182 | } |
| 183 | |
| 184 | func renderPanic(x interface{}) string { |
| 185 | buf := make([]byte, 16<<10) // 16 KB should be plenty |
no test coverage detected
searching dependent graphs…