Skip to content
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

feat: finish interceptors migration #782

Merged
merged 2 commits into from
Jul 22, 2024
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
19 changes: 1 addition & 18 deletions Sources/ClientRuntime/Endpoints/EndpointResolverMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import struct SmithyHTTPAuthAPI.SelectedAuthScheme
import enum SmithyHTTPAuthAPI.SigningAlgorithm
import enum SmithyHTTPAuthAPI.SigningPropertyKeys

public struct EndpointResolverMiddleware<OperationStackOutput, Params: EndpointsRequestContextProviding>: Middleware {
public struct EndpointResolverMiddleware<OperationStackOutput, Params: EndpointsRequestContextProviding> {
public let id: Swift.String = "EndpointResolverMiddleware"

let endpointResolverBlock: (Params) throws -> Endpoint
Expand All @@ -31,23 +31,6 @@ public struct EndpointResolverMiddleware<OperationStackOutput, Params: Endpoints
self.endpointParams = endpointParams
self.authSchemeResolver = authSchemeResolver
}

public func handle<H>(
context: Smithy.Context,
input: HTTPRequestBuilder,
next: H
) async throws -> OperationOutput<OperationStackOutput>
where H: Handler,
Self.MInput == H.Input,
Self.MOutput == H.Output {
let selectedAuthScheme = context.selectedAuthScheme
let request = input.build()
let updatedRequest =
try await apply(request: request, selectedAuthScheme: selectedAuthScheme, attributes: context)
return try await next.handle(context: context, input: updatedRequest.toBuilder())
}
public typealias MInput = HTTPRequestBuilder
public typealias MOutput = OperationOutput<OperationStackOutput>
}

extension EndpointResolverMiddleware: ApplyEndpoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@

import class Smithy.Context

public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutput>: Middleware {
public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutput> {
public let id: Swift.String = "IdempotencyTokenMiddleware"
private let keyPath: WritableKeyPath<OperationStackInput, String?>

public init(keyPath: WritableKeyPath<OperationStackInput, String?>) {
self.keyPath = keyPath
}

public func handle<H>(context: Smithy.Context,
input: MInput,
next: H) async throws -> MOutput
where H: Handler, Self.MInput == H.Input, Self.MOutput == H.Output {
let withToken = addToken(input: input, attributes: context)
return try await next.handle(context: context, input: withToken)
}

private func addToken(input: OperationStackInput, attributes: Smithy.Context) -> OperationStackInput {
var copiedInput = input
if input[keyPath: keyPath] == nil {
Expand All @@ -31,10 +23,6 @@ public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutp
}
return copiedInput
}

public typealias MInput = OperationStackInput
public typealias MOutput = OperationOutput<OperationStackOutput>
public typealias Context = Smithy.Context
}

extension IdempotencyTokenMiddleware: HttpInterceptor {
Expand Down
26 changes: 0 additions & 26 deletions Sources/ClientRuntime/Middleware/AnyHandler.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Sources/ClientRuntime/Middleware/AnyMiddleware.swift

This file was deleted.

33 changes: 0 additions & 33 deletions Sources/ClientRuntime/Middleware/ComposedHandler.swift

This file was deleted.

21 changes: 0 additions & 21 deletions Sources/ClientRuntime/Middleware/Handler.swift

This file was deleted.

12 changes: 0 additions & 12 deletions Sources/ClientRuntime/Middleware/HandlerFunction.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Sources/ClientRuntime/Middleware/Middleware.swift

This file was deleted.

11 changes: 0 additions & 11 deletions Sources/ClientRuntime/Middleware/MiddlewareFunction.swift

This file was deleted.

69 changes: 0 additions & 69 deletions Sources/ClientRuntime/Middleware/MiddlewareStep.swift

This file was deleted.

21 changes: 0 additions & 21 deletions Sources/ClientRuntime/Middleware/NoopHandler.swift

This file was deleted.

Loading
Loading