Instantly share code, notes, and snippets.

@xguox /main.go Secret
Last active Jan 22, 2019

Embed
What would you like to do?
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