Browse Source

Merge pull request #161 from qor5/new-mux-to-avoid-default-pprof-impact

new mux to avoid default net/http/pprof impact
xuxinx 1 year ago
parent
commit
9c2f41efb3
1 changed files with 6 additions and 4 deletions
  1. 6 4
      example/main.go

+ 6 - 4
example/main.go

@@ -10,21 +10,23 @@ import (
 )
 
 func main() {
-	mux := admin.Router()
+	h := admin.Router()
 
 	port := os.Getenv("PORT")
 	if len(port) == 0 {
 		port = "9000"
 	}
 	fmt.Println("Served at http://localhost:" + port)
-	http.Handle("/",
+
+	mux := http.NewServeMux()
+	mux.Handle("/",
 		middleware.RequestID(
 			middleware.Logger(
-				middleware.Recoverer(mux),
+				middleware.Recoverer(h),
 			),
 		),
 	)
-	err := http.ListenAndServe(":"+port, nil)
+	err := http.ListenAndServe(":"+port, mux)
 	if err != nil {
 		panic(err)
 	}