Last active
January 6, 2019 05:08
-
-
Save JenHsuan/9c39ccbe6f1d1a5ff57ab24820be9439 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
type car int | |
func (m car) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "text/html; charset=utf-8") | |
fmt.Fprintln(w, "<h1>car</h1>") | |
} | |
type plane int | |
func (m plane) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "text/html; charset=utf-8") | |
fmt.Fprintln(w, "<h1>plane</h1>") | |
} | |
func main() { | |
var c car | |
var p plane | |
mux := http.NewServeMux() | |
mux.Handle("/car", c) | |
mux.Handle("/plane", p) | |
http.ListenAndServe(":8080", mux) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment