-
Notifications
You must be signed in to change notification settings - Fork 35
chore!: Move CRT dependency from SmithyHTTPAPI to ClientRuntime #1003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initializer above is only called by
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, this is the place where this initializer is called from: |
||
| 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 { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This extension on |
||
|
|
||
| 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)) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| import enum AwsCommonRuntimeKit.EndpointProperty | ||
| import Foundation | ||
| import Smithy | ||
|
|
||
|
|
@@ -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) | ||
| } | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code above is moved to |
||
| extension Endpoint { | ||
|
|
||
| /// Returns list of auth schemes | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| import enum AwsCommonRuntimeKit.EndpointProperty | ||
| import Foundation | ||
| import Smithy | ||
|
|
||
|
|
@@ -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)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
There was a problem hiding this comment.
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
SmithyHTTPAPIsince no remaining types inSmithyHTTPAPIreference it.