File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/main/java/com/example/demo/handler Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .example .demo .handler ;
2+
3+ import com .amazonaws .serverless .exceptions .ContainerInitializationException ;
4+ import com .amazonaws .serverless .proxy .model .AwsProxyRequest ;
5+ import com .amazonaws .serverless .proxy .model .AwsProxyResponse ;
6+ import com .amazonaws .serverless .proxy .spring .SpringBootLambdaContainerHandler ;
7+ import com .amazonaws .services .lambda .runtime .Context ;
8+ import com .amazonaws .services .lambda .runtime .RequestStreamHandler ;
9+ import com .example .demo .DemoApplication ;
10+
11+ import java .io .IOException ;
12+ import java .io .InputStream ;
13+ import java .io .OutputStream ;
14+
15+ public class StreamLambdaHandler implements RequestStreamHandler {
16+
17+ private static SpringBootLambdaContainerHandler <AwsProxyRequest , AwsProxyResponse > handler ;
18+
19+ static {
20+ try {
21+ handler = SpringBootLambdaContainerHandler .getAwsProxyHandler (DemoApplication .class );
22+ } catch (ContainerInitializationException e ) {
23+ // If we fail here, re-throw the exception to force another cold start
24+ e .printStackTrace ();
25+ throw new RuntimeException ("Could not initialize Spring Boot application" , e );
26+ }
27+ }
28+
29+ @ Override
30+ public void handleRequest (InputStream inputStream , OutputStream outputStream , Context context )
31+ throws IOException {
32+ handler .proxyStream (inputStream , outputStream , context );
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments