Skip to content

Commit

Permalink
Test for fortio/log#70
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Oct 2, 2024
1 parent 2ebb2ca commit eccbae2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tinyhttp_std/smallhttpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ func helloHandler(w http.ResponseWriter, r *http.Request) {
}
}

func panicHandler1(w http.ResponseWriter, r *http.Request) {
panic("Direct Panic for testing")
}

func panicHandler2(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, before panic!"))
panic("Panic for testing, after writing")
}

func main() {
timeout := dflag.New(3*time.Second, "timeout for the http server")
dflag.Flag("timeout", timeout)
Expand All @@ -51,6 +60,8 @@ func main() {
Handler: mux,
ErrorLog: log.NewStdLogger("http srv", log.Error),
}
mux.HandleFunc("/panic1", log.LogAndCall("http srv", panicHandler1))
mux.HandleFunc("/panic2", log.LogAndCall("http srv", panicHandler2))
mux.HandleFunc("/", log.LogAndCall("http srv", helloHandler))
dflagEndpoint := endpoint.NewFlagsEndpoint(flag.CommandLine, "/flags/set")
mux.HandleFunc("/flags", log.LogAndCall("dflags-get", dflagEndpoint.ListFlags))
Expand Down

0 comments on commit eccbae2

Please sign in to comment.