diff options
| author | Christian Cleberg <[email protected]> | 2026-04-15 15:29:57 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-15 15:30:40 -0500 |
| commit | 06c36c4352f47655cb39a5042a7e5fd475c118e1 (patch) | |
| tree | 448054ebc937a258c694ed2338a7c2f7edbd17f2 /Hutch/Extensions | |
| parent | 3727afa0fdb6e7b9884bbe00b9aed3e994952c5a (diff) | |
| download | hutch-06c36c4352f47655cb39a5042a7e5fd475c118e1.tar.gz hutch-06c36c4352f47655cb39a5042a7e5fd475c118e1.tar.bz2 hutch-06c36c4352f47655cb39a5042a7e5fd475c118e1.zip | |
feat: add custom hutch user-agent to api calls
Implements: https://todo.sr.ht/~ccleberg/hutch/64
Diffstat (limited to 'Hutch/Extensions')
| -rw-r--r-- | Hutch/Extensions/Bundle+UserAgent.swift | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Hutch/Extensions/Bundle+UserAgent.swift b/Hutch/Extensions/Bundle+UserAgent.swift new file mode 100644 index 0000000..2200576 --- /dev/null +++ b/Hutch/Extensions/Bundle+UserAgent.swift @@ -0,0 +1,14 @@ +import Foundation + +extension Bundle { + /// The HTTP `User-Agent` string sent with all Hutch network requests. + /// + /// Format: `Hutch/<version>` + var hutchUserAgent: String { + let name = (object(forInfoDictionaryKey: "CFBundleDisplayName") as? String) + ?? (object(forInfoDictionaryKey: "CFBundleName") as? String) + ?? "Hutch" + let version = (object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String) ?? "dev" + return "\(name)/\(version)" + } +} |
