Skip to content

Instantly share code, notes, and snippets.

@xguox

xguox/main.go Secret

Last active January 22, 2019 08:14
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 xguox/f0603d9e3ef48148d4bd84fa209c6de5 to your computer and use it in GitHub Desktop.
Save xguox/f0603d9e3ef48148d4bd84fa209c6de5 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"net/http"
_ "net/http/pprof"
)
func main() {
http.Handle("/", &MyHandler{})
http.Handle("/hello", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("world"))
}))
http.HandleFunc("/ping", hello)
http.ListenAndServe(":8080", nil)
}
func hello(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("pong"))
}
type MyHandler struct{}
func (m *MyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("MyHandler ServeHTTP"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment