(next http.Handler)
| 130 | } |
| 131 | |
| 132 | func executeRequestSafelyMiddleware(next http.Handler) http.Handler { |
| 133 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 134 | defer func() { |
| 135 | if x := recover(); x != nil { |
| 136 | c := w.(*aeContext) |
| 137 | logf(c, 4, "%s", renderPanic(x)) // 4 == critical |
| 138 | c.outCode = 500 |
| 139 | } |
| 140 | }() |
| 141 | |
| 142 | next.ServeHTTP(w, r) |
| 143 | }) |
| 144 | } |
| 145 | |
| 146 | func renderPanic(x interface{}) string { |
| 147 | buf := make([]byte, 16<<10) // 16 KB should be plenty |
no test coverage detected
searching dependent graphs…