func main() { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello from " + r.RemoteAddr + "\n")) }) mux := mux.NewRouter() mux.Handle("/", handler) n := negroni.Classic() n.Use(negroni.HandlerFunc(xff.XFF)) n.UseHandler(mux) n.Run(":3000") }
// Inject adds x-request-id and x-forwarded-for support to an existing negroni instance. func Inject(n *negroni.Negroni) { n.Use(negroni.HandlerFunc(xff.XFF)) n.Use(xrequestid.New(26)) }