Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ let package = Package(
),
.target(
name: "SmithyHTTPAPI",
dependencies: [
"Smithy",
.product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift")
]
dependencies: ["Smithy"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRT dependency is removed from SmithyHTTPAPI since no remaining types in SmithyHTTPAPI reference it.

),
.target(
name: "SmithyHTTPClient",
Expand Down
43 changes: 43 additions & 0 deletions Sources/ClientRuntime/Networking/Http/CRT/Endpoint+CRT.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import enum AwsCommonRuntimeKit.EndpointProperty
import struct Foundation.URLComponents
import enum Smithy.ClientError
import struct SmithyHTTPAPI.Endpoint
import enum SmithyHTTPAPI.EndpointPropertyValue
import struct SmithyHTTPAPI.Headers

extension Endpoint {

public init(urlString: String,
headers: Headers = Headers(),
endpointProperties: [String: EndpointProperty]) throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initializer above is only called by DefaultEndpointResolver so it is moved here from SmithyHTTPAPI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard let url = URLComponents(string: urlString)?.url else {
throw ClientError.unknownError("invalid url \(urlString)")
}

let properties = endpointProperties.mapValues(EndpointPropertyValue.init)
try self.init(url: url, headers: headers, properties: properties)
}
}

private extension EndpointPropertyValue {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension on EndpointPropertyValue is only called from the initializer above, so it is moved here & scoped private.


init(_ endpointProperty: EndpointProperty) {
switch endpointProperty {
case .bool(let value):
self = .bool(value)
case .string(let value):
self = .string(value)
case .array(let values):
self = .array(values.map(EndpointPropertyValue.init))
case .dictionary(let dict):
self = .dictionary(dict.mapValues(EndpointPropertyValue.init))
}
}
}
14 changes: 0 additions & 14 deletions Sources/SmithyHTTPAPI/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// SPDX-License-Identifier: Apache-2.0
//

import enum AwsCommonRuntimeKit.EndpointProperty
import Foundation
import Smithy

Expand Down Expand Up @@ -80,19 +79,6 @@ public struct Endpoint: Sendable, Equatable {
}
}

extension Endpoint {
public init(urlString: String,
headers: Headers = Headers(),
endpointProperties: [String: EndpointProperty]) throws {
guard let url = URLComponents(string: urlString)?.url else {
throw ClientError.unknownError("invalid url \(urlString)")
}

let properties = endpointProperties.mapValues(EndpointPropertyValue.init)
try self.init(url: url, headers: headers, properties: properties)
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code above is moved to ClientRuntime to be with the DefaultEndpointResolver that calls it.

extension Endpoint {

/// Returns list of auth schemes
Expand Down
16 changes: 0 additions & 16 deletions Sources/SmithyHTTPAPI/EndpointPropertyValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// SPDX-License-Identifier: Apache-2.0
//

import enum AwsCommonRuntimeKit.EndpointProperty
import Foundation
import Smithy

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

extension EndpointPropertyValue {
init(_ endpointProperty: EndpointProperty) {
switch endpointProperty {
case .bool(let value):
self = .bool(value)
case .string(let value):
self = .string(value)
case .array(let values):
self = .array(values.map(EndpointPropertyValue.init))
case .dictionary(let dict):
self = .dictionary(dict.mapValues(EndpointPropertyValue.init))
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension above was only ever called by the initializer in the file above.

extension EndpointPropertyValue: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self = .string(value)
Expand Down
Loading