Skip to content

Commit 144886b

Browse files
authored
chore!: Move CRT dependency from SmithyHTTPAPI to ClientRuntime (#1003)
1 parent edbd061 commit 144886b

File tree

4 files changed

+44
-34
lines changed

4 files changed

+44
-34
lines changed

Package.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ let package = Package(
208208
),
209209
.target(
210210
name: "SmithyHTTPAPI",
211-
dependencies: [
212-
"Smithy",
213-
.product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift")
214-
]
211+
dependencies: ["Smithy"]
215212
),
216213
.target(
217214
name: "SmithyHTTPClient",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import enum AwsCommonRuntimeKit.EndpointProperty
9+
import struct Foundation.URLComponents
10+
import enum Smithy.ClientError
11+
import struct SmithyHTTPAPI.Endpoint
12+
import enum SmithyHTTPAPI.EndpointPropertyValue
13+
import struct SmithyHTTPAPI.Headers
14+
15+
extension Endpoint {
16+
17+
public init(urlString: String,
18+
headers: Headers = Headers(),
19+
endpointProperties: [String: EndpointProperty]) throws {
20+
guard let url = URLComponents(string: urlString)?.url else {
21+
throw ClientError.unknownError("invalid url \(urlString)")
22+
}
23+
24+
let properties = endpointProperties.mapValues(EndpointPropertyValue.init)
25+
try self.init(url: url, headers: headers, properties: properties)
26+
}
27+
}
28+
29+
private extension EndpointPropertyValue {
30+
31+
init(_ endpointProperty: EndpointProperty) {
32+
switch endpointProperty {
33+
case .bool(let value):
34+
self = .bool(value)
35+
case .string(let value):
36+
self = .string(value)
37+
case .array(let values):
38+
self = .array(values.map(EndpointPropertyValue.init))
39+
case .dictionary(let dict):
40+
self = .dictionary(dict.mapValues(EndpointPropertyValue.init))
41+
}
42+
}
43+
}

Sources/SmithyHTTPAPI/Endpoint.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
import enum AwsCommonRuntimeKit.EndpointProperty
98
import Foundation
109
import Smithy
1110

@@ -80,19 +79,6 @@ public struct Endpoint: Sendable, Equatable {
8079
}
8180
}
8281

83-
extension Endpoint {
84-
public init(urlString: String,
85-
headers: Headers = Headers(),
86-
endpointProperties: [String: EndpointProperty]) throws {
87-
guard let url = URLComponents(string: urlString)?.url else {
88-
throw ClientError.unknownError("invalid url \(urlString)")
89-
}
90-
91-
let properties = endpointProperties.mapValues(EndpointPropertyValue.init)
92-
try self.init(url: url, headers: headers, properties: properties)
93-
}
94-
}
95-
9682
extension Endpoint {
9783

9884
/// Returns list of auth schemes

Sources/SmithyHTTPAPI/EndpointPropertyValue.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
import enum AwsCommonRuntimeKit.EndpointProperty
98
import Foundation
109
import Smithy
1110

@@ -22,21 +21,6 @@ public extension EndpointPropertyValue {
2221
init(_ bool: Bool) { self = .bool(bool) }
2322
}
2423

25-
extension EndpointPropertyValue {
26-
init(_ endpointProperty: EndpointProperty) {
27-
switch endpointProperty {
28-
case .bool(let value):
29-
self = .bool(value)
30-
case .string(let value):
31-
self = .string(value)
32-
case .array(let values):
33-
self = .array(values.map(EndpointPropertyValue.init))
34-
case .dictionary(let dict):
35-
self = .dictionary(dict.mapValues(EndpointPropertyValue.init))
36-
}
37-
}
38-
}
39-
4024
extension EndpointPropertyValue: ExpressibleByStringLiteral {
4125
public init(stringLiteral value: String) {
4226
self = .string(value)

0 commit comments

Comments
 (0)