Skip to content

Commit 23e8c79

Browse files
committed
Add settings for websocket response mode
1 parent 5cc01a0 commit 23e8c79

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

aws/adaptor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import (
1414
var DEBUGDumpPayload = os.Getenv("DEBUG_DUMP_PAYLOAD")
1515
var LambdaInvokeMode = os.Getenv("LAMBDA_INVOKE_MODE")
1616

17+
// WebsocketResponseMode
18+
// * return - use lambda return value as response
19+
// * post_to_connection - use PostToConnection API to send response
20+
var WebsocketResponseMode = os.Getenv("WEBSOCKET_RESPONSE_MODE")
21+
1722
type LambdaIntegrationType int
1823

1924
const (

aws/lambda.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (l *LambdaHandler) InvokeWebsocketAPI(ctx context.Context, request *events.
166166

167167
routeKey := request.RequestContext.RouteKey
168168

169-
if routeKey == "$connect" || routeKey == "$disconnect" {
169+
if routeKey == "$connect" || routeKey == "$disconnect" || WebsocketResponseMode == "return" {
170170
w := NewResponseWriter()
171171
l.httpHandler.ServeHTTP(w, req)
172172
return RESTAPITargetResponse(w, multiValue)

0 commit comments

Comments
 (0)