@@ -45,14 +45,15 @@ func WithoutNonHTTPEventPassThrough() LambdaHandlerOption {
45
45
}
46
46
47
47
type LambdaHandler struct {
48
- httpHandler http.Handler
49
- sessProv SDKSessionProvider
50
- sess * session.Session
51
- confProv SDKConfigProvider
52
- conf * aws.Config
53
- apiGW APIGatewayManagementAPI
54
- wsPathPrefix string
55
- nonHTTPEventPath string
48
+ httpHandler http.Handler
49
+ sessProv SDKSessionProvider
50
+ sess * session.Session
51
+ confProv SDKConfigProvider
52
+ conf * aws.Config
53
+ apiGW APIGatewayManagementAPI
54
+ wsPathPrefix string
55
+ nonHTTPEventPath string
56
+ invokeLambdaWithStream func (ctx context.Context , request * events.LambdaFunctionURLRequest ) (* events.LambdaFunctionURLStreamingResponse , error )
56
57
}
57
58
58
59
type HandlerFunc func (ctx context.Context , payload json.RawMessage ) (res any , err error )
@@ -63,8 +64,9 @@ func NewLambdaHandlerWithOption(h http.Handler, options []interface{}) *LambdaHa
63
64
confProv : func (ctx context.Context ) (aws.Config , error ) {
64
65
return config .LoadDefaultConfig (ctx )
65
66
},
66
- wsPathPrefix : DefaultWebsocketPathPrefix ,
67
- nonHTTPEventPath : DefaultNonHTTPEventPath ,
67
+ wsPathPrefix : DefaultWebsocketPathPrefix ,
68
+ nonHTTPEventPath : DefaultNonHTTPEventPath ,
69
+ invokeLambdaWithStream : lambdaurl .Wrap (h ),
68
70
}
69
71
70
72
for _ , opt := range options {
@@ -213,11 +215,19 @@ func (l *LambdaHandler) Invoke(ctx context.Context, payload json.RawMessage) (re
213
215
}
214
216
res , err = l .InvokeWebsocketAPI (ctx , event )
215
217
case LambdaFunctionURLIntegration :
216
- event := & events.LambdaFunctionURLRequest {}
217
- if err := json .Unmarshal (payload , event ); err != nil {
218
- return nil , err
218
+ if LambdaInvokeMode == "response_stream" {
219
+ event := & events.LambdaFunctionURLRequest {}
220
+ if err := json .Unmarshal (payload , event ); err != nil {
221
+ return nil , err
222
+ }
223
+ res , err = l .invokeLambdaWithStream (ctx , event )
224
+ } else {
225
+ event := & events.APIGatewayV2HTTPRequest {}
226
+ if err := json .Unmarshal (payload , event ); err != nil {
227
+ return nil , err
228
+ }
229
+ res , err = l .InvokeHTTPAPI (ctx , event )
219
230
}
220
- res , err = lambdaurl .Wrap (l .httpHandler )(ctx , event )
221
231
default :
222
232
res , err = l .HandleNonHTTPEvent (ctx , payload , "application/json" )
223
233
}
0 commit comments