Skip to content

Instantly share code, notes, and snippets.

@LukeHandle
Created October 3, 2015 15:01
Show Gist options
  • Save LukeHandle/07aa30643dbf260053a8 to your computer and use it in GitHub Desktop.
Save LukeHandle/07aa30643dbf260053a8 to your computer and use it in GitHub Desktop.
Inserting HTTP Header before handler
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