News for hackers. Stuff that matters.
Re:API design: Which version of versioning is right for you? by jmartrican on Sunday October 06, 2019 @05:32PM (#21175312)
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.

Re:API design: Which version of versioning is right for you? by segmondy on Sunday October 06, 2019 @05:57PM (#21175449)

   func 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.
Re:API design: Which version of versioning is right for you? by dariusj18 on Monday October 07, 2019 @03:34PM (#21185030)
Or, you could just deploy a copy of each version of the code using a reverse proxy.