alamofire

Alamofire

HTTP networking library for Swift

Details

Language / Topic
swiftSwift
Category
Libraries
Source
Alamofire

Rules

balanced
- Use `AF.request(url).responseDecodable(of: T.self)` for type-safe API responses — Alamofire handles JSON decoding with `Codable` automatically.
- Use `Session` with custom `URLSessionConfiguration` for auth interceptors, retry policies, and certificate pinning — don't modify the default `AF` session.
- Use request adapters (`RequestAdapter`) to inject auth tokens and retriers (`RequestRetrier`) to handle 401s with automatic token refresh.
- Use `ParameterEncoder` (JSON or URL) for request parameters instead of manual serialization.
- Use `RequestInterceptor` for auth token injection and automatic token refresh.
- Use `validate()` to check status codes and content types before decoding.
- Use `async`/`await` with `AF.request(url).serializingDecodable(T.self).value`.