mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 07:35:51 +08:00
Recover from panic during requests
This commit is contained in:
@ -101,6 +101,11 @@ func (s *Server) Serve() error {
|
|||||||
|
|
||||||
// ServeHTTP is the entry point for each request to s.
|
// ServeHTTP is the entry point for each request to s.
|
||||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer func() {
|
||||||
|
if rec := recover(); rec != nil {
|
||||||
|
log.Printf("[PANIC] '%s': %s", r.URL.String(), rec)
|
||||||
|
}
|
||||||
|
}()
|
||||||
s.stack(w, r)
|
s.stack(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user