steamclock / netable

A Swift library for encapsulating network APIs using Codable in a type-oriented way.
MIT License
99 stars 3 forks source link

Add support for request interceptors #119

Closed brendanlensink closed 1 year ago

brendanlensink commented 1 year ago

For #118

This PR isn't anywhere near ready to go, but since things are a little complex I thought it might make sense to do a quick validation check before polishing all the rough edges.

With that in mind, this PR adds a prototype for request Interceptors, which are intended to allow users to modify Netable Requests at runtime and do things like add headers, mock out endpoints, or whatever else they'd like.

A couple goals/intended patterns:

While I think there's an argument to be made for simplifying things and not allowing chainable interceptors, I think it's a little more awkward to change our minds later and add in that functionality after the fact, so if it's not too much more work to make interceptors able to chain now that feels like it's worth doing to me.

nbrooke commented 1 year ago

Added a few comments, but looks fairly reasonable overall.

brendanlensink commented 1 year ago

Updated to include examples, documentation and all the changes we've discussed. I think we're ready for a real review now 🚀