Skip to content

Commit

Permalink
Add x-yorkie-user-agent (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
humdrum authored Mar 30, 2023
1 parent b5ec0be commit a32b919
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions Sources/Core/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AuthClientInterceptor<Request, Response>: ClientInterceptor<Request, Respo
header.add(name: "authorization", value: token)
}

header.add(name: "x-yorkie-user-agent", value: "yorkie-ios-sdk/\(yorkieVersion)")
part = .metadata(header)
default:
break
Expand Down
7 changes: 1 addition & 6 deletions Sources/Core/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,7 @@ public actor Client {

let channel = builder.connect(host: rpcAddress.host, port: rpcAddress.port)

let authInterceptors: AuthClientInterceptors?
if options.apiKey != nil || options.token != nil {
authInterceptors = AuthClientInterceptors(apiKey: options.apiKey, token: options.token)
} else {
authInterceptors = nil
}
let authInterceptors = AuthClientInterceptors(apiKey: options.apiKey, token: options.token)

self.rpcClient = YorkieServiceAsyncClient(channel: channel, interceptors: authInterceptors)
self.eventStream = PassthroughSubject()
Expand Down
19 changes: 19 additions & 0 deletions Sources/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2023 The Yorkie Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Foundation

let yorkieVersion = "0.3.3"

0 comments on commit a32b919

Please sign in to comment.