-
-
Save xguox/f0603d9e3ef48148d4bd84fa209c6de5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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