Rolling your own Network Stack
summary
Shows a concrete Swift network stack: uses URLSession, Codable and generics to build an API router enum that produces URLRequests, a NetworkService wrapping an OperationQueue, and a generic NetworkOperation subclass that decodes Decodable models (example: New York Times Bestsellers). Adds practical extensions: request adapter for auth headers, retry logic for OAuth token refresh, custom URLSession for pinning/caching, and custom decoders for weird JSON. Stack replaced an existing client at Coop to support a second API and works in production.
AI-written summary · about
chapters (7)
- 0:00Introduction and motivation
- 2:00From objective-c to swift
- 4:56Naive networking approach
- 7:39Implementing an API router
- 10:38Service and operation layers
- 14:26Generic networking
- 16:57Advanced networking tips
related talks
39mWe need to talk about Websockets
01h 01mStructured Networking
01h 23mBasic and advanced networking in Dart and Flutter
56mThe Qt Networking Stack
22mEvent driven networking for Swift
18mBuilding Networking Libraries with Span and Concurrency
19mRise of Network APIs
12mProgramming Network Stack for Middleboxes with Rubik
