Created
May 13, 2020 10:37
-
-
Save alibo/4669e2cfe9d51c0c1eaec8cb567349dc to your computer and use it in GitHub Desktop.
Simple http echo headers
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 main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | |
for name, headers := range req.Header { | |
for _, h := range headers { | |
fmt.Fprintf(w, "%v: %v\n", name, h) | |
} | |
} | |
}) | |
fmt.Println("running server on :8080 ...") | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment