3 ms·
One issue I see with HTTP header versioning, is that now I have to add the HTTP version header into my routing logic. I already have to take domain, sub-domain
by jmartrican 7y ago
One issue I see with HTTP header versioning, is that now I have to add the HTTP version header into my routing logic. I already have to take domain, sub-domain, protocol, HTTP-verb, application context, and path into account when considering routing of HTTP requests. When defining my API signature, I would now need to include more than just the URL path and verb, I would need to include the version header value. I can imagine troubleshooting with other engineers.. "wait can you look through the logs and verify the http version header you used for that request."
Also, I really like when one piece of data can serve dual purpose use. In this case, the URL, which is highly visible, contains the version in it. So the one string of data reveals more information to me.
- segmondy 7y agofunc metrics(w http.ResponseWriter, r *http.Request) { } func AddV1Routes(r *mux.Router) { r.HandleFunc("/metrics/", metrics).Methods("GET") r.HandleFunc("/v1func/", v1func).Methods("GET") } func AddV2Routes(r *mux.Router) { r.HandleFunc("/metrics/", metrics).Methods("GET") r.HandleFunc("/v2func/", v1func).Methods("GET") } r := mux.NewRouter() AddV1Routes(r.PathPrefix("/api/v1").Subrouter()) AddV2Routes(r.PathPrefix("/api/v2").Subrouter()) handler := c.Handler(r) http.ListenAndServe(":5000", handler With a pattern like this, you can just decide which functions to group by version.
- dariusj18 7y agoOr, you could just deploy a copy of each version of the code using a reverse proxy.