Skip to content

Commit

Permalink
send custom user agent in the request
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Sep 24, 2021
1 parent 1ab6074 commit d7c5291
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions BlockfrostSwiftSDK/Classes/BuildInfo.swift
@@ -0,0 +1,4 @@
import Foundation
public class BuildInfo {
public static let VERSION="0.0.2"
}
1 change: 1 addition & 0 deletions BlockfrostSwiftSDK/Classes/OpenAPIs/APIs.swift
Expand Up @@ -11,6 +11,7 @@ import Alamofire
//public typealias OpenAPIClientAPI = BlockfrostSDK

open class BlockfrostConfig {
public static let USER_AGENT = "BlockfrostSwiftSDK"
public static let URL_MAINNET = "https://cardano-mainnet.blockfrost.io/api/v0"
public static let URL_TESTNET = "https://cardano-testnet.blockfrost.io/api/v0"
public static let URL_IPFS = "https://ipfs.blockfrost.io/api/v0"
Expand Down
Expand Up @@ -75,6 +75,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
open func createSessionManager(rootQueue: DispatchQueue? = nil) -> Alamofire.Session {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = buildHeaders()
configuration.headers.add(.userAgent("\(BlockfrostConfig.USER_AGENT)-\(BuildInfo.VERSION)"))
let queue = rootQueue ?? DispatchQueue(label: "org.alamofire.session.rootQueue")
return Alamofire.Session(configuration: configuration, rootQueue: queue, interceptor: config.retryPolicy)
}
Expand Down
Expand Up @@ -58,6 +58,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
open func createURLSession() -> URLSession {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = buildHeaders()
configuration.headers.add(.userAgent("\(BlockfrostConfig.USER_AGENT)-\(BuildInfo.VERSION)"))
let sessionDelegate = SessionDelegate()
sessionDelegate.credential = credential
sessionDelegate.taskDidReceiveChallenge = taskDidReceiveChallenge
Expand Down

0 comments on commit d7c5291

Please sign in to comment.