Khan Winter @khanwinter.com · 20d

I think I figured out my new favorite way of doing strongly typed network requests in Swift. Previously I was doing a big `Resources` enum, which had a case for each path on the server, and a whole slew of type aliases for Request/Response types. 1/2

1 likes 1 replies

?

Replies

Khan Winter · 20d

I'm transitioning to this new method. A Channel type consumes a set of Request protocols. Requests have Request/Response associated types and a path. Request site is cleaner. The type checker can correctly guess response types without hints, and enforces bodies or lack of bodies for requests. 2/2