relevantCaller searches the call stack for the first function outside of net/http. The purpose of this function is to provide more helpful error messages.
()
| 177 | // relevantCaller searches the call stack for the first function outside of net/http. |
| 178 | // The purpose of this function is to provide more helpful error messages. |
| 179 | func relevantCaller() runtime.Frame { |
| 180 | pc := make([]uintptr, 16) |
| 181 | n := runtime.Callers(1, pc) |
| 182 | frames := runtime.CallersFrames(pc[:n]) |
| 183 | var frame runtime.Frame |
| 184 | for { |
| 185 | frame, more := frames.Next() |
| 186 | if !strings.HasPrefix(frame.Function, "net/http.") { |
| 187 | return frame |
| 188 | } |
| 189 | if !more { |
| 190 | break |
| 191 | } |
| 192 | } |
| 193 | return frame |
| 194 | } |
| 195 | |
| 196 | // logf prints to the ErrorLog of the *Server associated with request r |
| 197 | // via ServerContextKey. If there's no associated server, or if ErrorLog |