Quick Start
The Device Struct
Platform Types
ThePlatform type represents the client operating system:
Platform Methods
Header Parsing
The middleware parses these standard headers:| Header | Field | Example |
|---|---|---|
X-Device-ID | DeviceID | 550e8400-e29b-41d4-a716-446655440000 |
X-App-Version | AppVersion | 2.1.0 |
X-App-Build | AppBuild | 2024.01.15 |
X-Device-Model | DeviceModel | iPhone15,2 |
X-Platform | Platform | ios |
X-OS-Version | OSVersion | 17.0 |
X-Timezone | Timezone | America/New_York |
X-Locale | Locale | en-US |
X-Push-Token | PushToken | abc123... |
Platform Detection Priority
- Explicit header -
X-Platformheader takes priority - User-Agent parsing - Falls back to User-Agent analysis
- Unknown - Default if no detection succeeds
Configuration Options
Basic Options
Platform Restrictions
Minimum App Version
X-Min-App-Version: 1.5.0
Custom Error Handlers
Performance Optimization
Using Device Context
Access in Handlers
Platform-Specific Logic
Version-Based Features
Timezone-Aware Responses
Localized Responses
User-Agent Patterns
The middleware recognizes these User-Agent patterns: iOS:Client Implementation
iOS (Swift)
Android (Kotlin)
Flutter (Dart)
React Native (TypeScript)
Next Steps
API Versioning
Manage API versions with deprecation warnings
Structured Errors
Return consistent error responses
Push Notifications
Handle push token registration
API Reference
Complete API documentation