Created
December 29, 2018 06:15
-
-
Save JenHsuan/8c02f63e1e64c5737e70ebab69f867bb 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 ( | |
"fmt" | |
"net/http" | |
) | |
func Cat(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Mcleod-Key", "this is from mcleod") | |
w.Header().Set("Content-Type", "text/html; charset=utf-8") | |
fmt.Fprintln(w, "<h1>car</h1>") | |
} | |
func Plane(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Mcleod-Key", "this is from mcleod") | |
w.Header().Set("Content-Type", "text/html; charset=utf-8") | |
fmt.Fprintln(w, "<h1>plane</h1>") | |
} | |
func main() { | |
http.Handle("/car", http.HandlerFunc(Cat)) | |
http.Handle("/plane", http.HandlerFunc(Plane)) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment