Conversation
3ede508 to
fb1740a
Compare
majewsky
left a comment
There was a problem hiding this comment.
Removing gorilla/mux support all at once is too drastic of a change in my opinion. This would require immediately touching at least a dozen repos to update the API implementations. We should support a gradual move here.
I was initially considering something along the lines of
type API[Router interface { *mux.Router | *http.ServeMux }] interface {
AddTo(r Router)
}
func Compose[Router interface { *mux.Router | *http.ServeMux }](apis ...API[Router]) http.Handler {
...
}So then, each application can choose at compile time whether to use one or the other type. But this does not work for the API instances defined within this package (e.g. HealthCheckAPI) which would want to satisfy both interfaces. So we will definitely need to use separate names, and a new implementation should be added like:
type APIForServeMux interface {
AddToServeMux(m *http.ServeMux)
}
func ComposeUsingServeMux(apis ...HttpAPI) http.Handler {
...
}My main issue right now is that the type names are extremely awkward. I have not come up with good names here.
In fact, this is where I got stuck thinking about the problem a while ago, and why I didn't bother coming up with a PR myself yet.
No description provided.