Skip to content
Closed
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: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ let package = Package(
.target(name: "MockServer", dependencies: [
.product(name: "NIOHTTP1", package: "swift-nio"),
]),
.target(name: "StringSample", dependencies: ["AWSLambdaRuntime"]),
.target(name: "StringSample", dependencies: [
.byName(name: "AWSLambdaRuntime"),
.byName(name: "AWSLambdaTesting"),
]),
.target(name: "CodableSample", dependencies: ["AWSLambdaRuntime"]),
]
)
268 changes: 0 additions & 268 deletions Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift

This file was deleted.

33 changes: 33 additions & 0 deletions Sources/AWSLambdaTesting/APIGatewayV2Proxy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#if DEBUG
import AWSLambdaEvents
import NIO

struct APIGatewayV2Proxy: LocalLambdaInvocationProxy {
let eventLoop: EventLoop

init(eventLoop: EventLoop) {
self.eventLoop = eventLoop
}

func invocation(from request: HTTPRequest) -> EventLoopFuture<ByteBuffer> {
switch (request.method, request.uri) {
case (.POST, "/invoke"):
guard let body = request.body else {
return self.eventLoop.makeFailedFuture(InvocationHTTPError(.init(status: .badRequest)))
}
return self.eventLoop.makeSucceededFuture(body)
default:
return self.eventLoop.makeFailedFuture(InvocationHTTPError(.init(status: .notFound)))
}
}

func processResult(_ result: ByteBuffer?) -> EventLoopFuture<HTTPResponse> {
self.eventLoop.makeSucceededFuture(.init(status: .ok, body: result))
}

func processError(_ error: ByteBuffer?) -> EventLoopFuture<HTTPResponse> {
self.eventLoop.makeSucceededFuture(.init(status: .internalServerError, body: error))
}
}
#endif
Loading