-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
32 lines (26 loc) · 587 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/panic/", panicDemo)
mux.HandleFunc("/panic-after/", panicAfterDemo)
mux.HandleFunc("/", hello)
log.Fatal(http.ListenAndServe(":3000", mux))
}
func panicDemo(w http.ResponseWriter, r *http.Request) {
funcThatPanics()
}
func panicAfterDemo(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "<h1>Hello!</h1>")
funcThatPanics()
}
func funcThatPanics() {
panic("Oh no!")
}
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "<h1>Hello!</h1>")
}