socketry / protocol-http

MIT License
23 stars 20 forks source link

Should `Protocol::HTTP::Middleware` inherit from `Methods`? #26

Closed ioquatix closed 1 year ago

ioquatix commented 1 year ago

I investigated this design problem.

I don't like having root classes that have methods that might change over time. The possibility of clobbering downstream code is high.

We already have a general #call entry point. The class Methods introduces convenient methods that correspond to HTTP methods, e.g. #get and #post.

I've introduced additional documentation, but I'm still on edge about this design. I considered renaming the methods to http_get, http_post, and so on. However this is counter-intuitive to existing users and a breaking change.

In the future, when adding new HTTP methods, special care must be given to extending this interface, to avoid breaking downstream code.

As a conclusion, I decided not to make any changes to the interface.

ioquatix commented 1 year ago

One change I did make, while investigating this issue, was to update the traces gem and remove the def trace method that was added (monkey patched) into user's own classes. Because it would directly conflict with #trace. I felt like it was a poor design choice and was able to fix it.

https://github.com/socketry/traces/pull/8