Skip to content

Instantly share code, notes, and snippets.

@alibo
Created May 13, 2020 10:37
Show Gist options
  • Save alibo/4669e2cfe9d51c0c1eaec8cb567349dc to your computer and use it in GitHub Desktop.
Save alibo/4669e2cfe9d51c0c1eaec8cb567349dc to your computer and use it in GitHub Desktop.
Simple http echo headers
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