Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shorten middleware names due to swiftlint
Browse files Browse the repository at this point in the history
dayaffe committed Dec 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 35971c9 commit 3068334
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
import ClientRuntime
import SmithyHTTPAPI

public struct RpcV2CborValidateResponseHeaderMiddleware<Input, Output> {
public let id: Swift.String = "RpcV2CborValidateResponseHeaderMiddleware"
public struct CborValidateResponseHeaderMiddleware<Input, Output> {
public let id: Swift.String = "CborValidateResponseHeaderMiddleware"

public init() {}
}
@@ -19,7 +19,7 @@ public enum ServiceResponseError: Error {
case badHeaderValue(String)
}

extension RpcV2CborValidateResponseHeaderMiddleware: Interceptor {
extension CborValidateResponseHeaderMiddleware: Interceptor {

public typealias InputType = Input
public typealias OutputType = Output
@@ -31,11 +31,15 @@ extension RpcV2CborValidateResponseHeaderMiddleware: Interceptor {
let smithyProtocolHeader = response.headers.value(for: "smithy-protocol")

guard let smithyProtocolHeader else {
throw ServiceResponseError.missingHeader("smithy-protocol header is missing from a response over RpcV2 Cbor!")
throw ServiceResponseError.missingHeader(
"smithy-protocol header is missing from a response over RpcV2 Cbor!"
)
}

guard smithyProtocolHeader == "rpc-v2-cbor" else {
throw ServiceResponseError.badHeaderValue("smithy-protocol header is set to \(smithyProtocolHeader) instead of expected value rpc-v2-cbor")
throw ServiceResponseError.badHeaderValue(
"smithy-protocol header is set to \(smithyProtocolHeader) instead of expected value rpc-v2-cbor"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ class RpcV2CborProtocolGenerator : AWSHTTPBindingProtocolGenerator(RpcV2CborCust
)

operationMiddleware.appendMiddleware(operation, smithyProtocolRequestHeaderMiddleware)
operationMiddleware.appendMiddleware(operation, RpcV2CborValidateResponseHeaderMiddleware)
operationMiddleware.appendMiddleware(operation, CborValidateResponseHeaderMiddleware)

if (operation.hasHttpBody(ctx)) {
operationMiddleware.appendMiddleware(operation, ContentTypeMiddleware(ctx.model, ctx.symbolProvider, contentTypeValue, true))
Original file line number Diff line number Diff line change
@@ -13,14 +13,14 @@ import software.amazon.smithy.swift.codegen.integration.middlewares.handlers.Mid
import software.amazon.smithy.swift.codegen.middleware.MiddlewareRenderable
import software.amazon.smithy.swift.codegen.model.shapes

class RpcV2CborValidateResponseHeaderIntegration : SwiftIntegration {
class CborValidateResponseHeaderIntegration : SwiftIntegration {
override fun enabledForService(model: Model, settings: SwiftSettings): Boolean = model
.shapes<ServiceShape>()
.any { it.hasTrait(Rpcv2CborTrait::class.java) }
}

object RpcV2CborValidateResponseHeaderMiddleware : MiddlewareRenderable {
override val name = "RpcV2CborValidateResponseHeaderMiddleware"
object CborValidateResponseHeaderMiddleware : MiddlewareRenderable {
override val name = "CborValidateResponseHeaderMiddleware"

override fun renderMiddlewareInit(
ctx: ProtocolGenerator.GenerationContext,
@@ -31,7 +31,7 @@ object RpcV2CborValidateResponseHeaderMiddleware : MiddlewareRenderable {
val outputShapeName = MiddlewareShapeUtils.outputSymbol(ctx.symbolProvider, ctx.model, op).name
writer.write(
"\$N<\$L, \$L>()",
AWSClientRuntimeTypes.RpcV2Cbor.RpcV2CborValidateResponseHeaderMiddleware,
AWSClientRuntimeTypes.RpcV2Cbor.CborValidateResponseHeaderMiddleware,
inputShapeName,
outputShapeName,
)
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ object AWSClientRuntimeTypes {

object RpcV2Cbor {
val RpcV2CborError = runtimeSymbol("RpcV2CborError", SwiftDeclaration.STRUCT, listOf("SmithyReadWrite"))
val RpcV2CborValidateResponseHeaderMiddleware = runtimeSymbol("RpcV2CborValidateResponseHeaderMiddleware", SwiftDeclaration.STRUCT)
val CborValidateResponseHeaderMiddleware = runtimeSymbol("CborValidateResponseHeaderMiddleware", SwiftDeclaration.STRUCT)
}

object Core {

0 comments on commit 3068334

Please sign in to comment.