Last active
June 14, 2020 11:16
-
-
Save jmrobles/e77b1217c9779e81a27d93a1df81575f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hello(w http.ResponseWriter, req *http.Request) { | |
fmt.Fprintf(w, "hello\n") | |
} | |
func headers(w http.ResponseWriter, req *http.Request) { | |
for name, headers := range req.Header { | |
for _, h := range headers { | |
fmt.Fprintf(w, "%v: %v\n", name, h) | |
} | |
} | |
} | |
func main() { | |
http.HandleFunc("/hello", hello) | |
http.HandleFunc("/headers", headers) | |
fmt.Printf("Simple HTTP Server ready!\n") | |
http.ListenAndServe(":8090", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment