Skip to content

Instantly share code, notes, and snippets.

@miku
Last active February 2, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miku/9836026cacc170ad5bf7530a75fec777 to your computer and use it in GitHub Desktop.
Save miku/9836026cacc170ad5bf7530a75fec777 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"log"
"net/http"
selfdiagnose "github.com/emicklei/go-selfdiagnose"
"github.com/gorilla/mux"
)
func homeHandler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "home")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", homeHandler)
r.HandleFunc("/debug", selfdiagnose.HandleSelfdiagnose)
selfdiagnose.AddInternalHandlers()
// when handler (nil) gets replaced with mux (r), then the
// handlers in package selfdiagnose are not "active"
// err := http.ListenAndServe(":8080", nil)
err := http.ListenAndServe(":8080", r)
if err != nil {
log.Println(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment