Skip to content

Commit 1fd2c24

Browse files
committed
Set User-Agent header with SDK version
1 parent 98ab9fd commit 1fd2c24

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

Sources/ipinfoKit/API/API.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Service {
4747
var ipInfoURL = "https://ipinfo.io"
4848
let headers: HTTPHeaders = [
4949
"Authorization": "Bearer \(Constants.ACCESS_TOKEN)",
50+
"User-Agent": "IPinfoClient/Swift/\(Constants.SDK_VERSION)",
5051
]
5152

5253
@MainActor

Sources/ipinfoKit/Batch/Batch.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ extension IPINFO {
107107
let headers = [
108108
"Authorization": "Bearer \(Constants.ACCESS_TOKEN)",
109109
"Content-Type": "application/json",
110+
"User-Agent": "IPinfoClient/Swift/\(Constants.SDK_VERSION)"
110111
]
111112
// Create the URL request with appropriate method, headers, and body
112113
var request = URLRequest(url: URL(string: Service.Router.batch(withFilter: withFilter).endPoint)!)

Sources/ipinfoKit/Constant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Foundation
66
open class Constants {
77

88
static let shared = Constants()
9+
10+
static var SDK_VERSION: String = "0.2.0"
911

1012
/// Getting Application Version from info.plist
1113
static var APP_VERSION: String {

Sources/ipinfoKit/IPInfoLite.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ open class IPInfoLite {
2323
"accept": "application/json",
2424
"authorization": "Bearer \(token)",
2525
"content-type": "application/json",
26+
"user-agent": "IPinfoClient/Swift/\(Constants.SDK_VERSION)",
2627
]
2728

2829
let (data, response) = try await urlSession.data(for: urlRequest)

0 commit comments

Comments
 (0)