Type-Safe Endpoints
PrismNetworkEndpoint is the foundation of PrismNetwork. Each endpoint describes a single API call — the URL, HTTP method, headers, body, and caching behavior. Typically modeled as an enum with one case per API operation.
PrismNetworkEndpoint Protocol
Protocol Definition
host and path are required — everything else has a default value.
Enum-Based Pattern
The recommended pattern is one enum per API domain:ProductEndpoint.swift
HTTP Methods
PrismNetworkMethod supports all standard methods:
URL Schemes
PrismNetworkScheme supports HTTP, HTTPS, and WebSocket protocols:
Content Types
PrismNetworkHeaderType provides constants for common Content-Type values:
Header Types
Computed URL & Request
Every endpoint exposes a computedurl and request built from its properties:
URL Construction
Caching Behavior
SetcacheInterval to enable automatic response caching for GET requests:
Endpoint Caching
PrismNetworkAdapter stores responses in URLCache with an expiration timestamp. On subsequent requests:
- If a cached response exists and hasn’t expired → returns cached data
- If cached data exists but can’t be decoded → evicts the entry and fetches fresh
- If no cache or expired → fetches from network and caches the result
Timeout Configuration
SettimeoutInterval to override the default URLSession timeout:
Custom Timeout
Authentication Patterns
Add authentication headers per-endpoint:Auth Headers
Next Steps
Network Client
Execute endpoints through PrismNetworkClient.
Caching & Retry
Advanced caching policies and retry strategies.