Created
October 3, 2015 15:01
-
-
Save LukeHandle/07aa30643dbf260053a8 to your computer and use it in GitHub Desktop.
Inserting HTTP Header before handler
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
func startServer(listen string) { | |
r := Router{Mux: mux.NewRouter()} | |
r.Bind() | |
//http.Handle("/", r.Mux) | |
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | |
w.Header().Set("Header", "Here") | |
r.Mux.ServeHTTP(w, req) | |
}) | |
log.Printf("Starting on %s", listen) | |
err := http.ListenAndServe(listen, nil) | |
if err != nil { | |
log.Fatal("ListenAndServe: \"%s\"", err.Error()) | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment