This repository was archived by the owner on Feb 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Function/src/main/java/helloworld Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ package helloworld ;
2
+
3
+ import java .io .IOException ;
4
+ import java .io .InputStream ;
5
+ import java .io .OutputStream ;
6
+ import java .util .Map ;
7
+
8
+ import com .amazonaws .services .lambda .runtime .Context ;
9
+ import com .amazonaws .services .lambda .runtime .RequestStreamHandler ;
10
+ import com .fasterxml .jackson .databind .ObjectMapper ;
11
+ import software .amazon .lambda .powertools .logging .Logging ;
12
+ import software .amazon .lambda .powertools .metrics .Metrics ;
13
+
14
+ public class AppStream implements RequestStreamHandler {
15
+ private static final ObjectMapper mapper = new ObjectMapper ();
16
+
17
+ @ Override
18
+ @ Logging (logEvent = true )
19
+ @ Metrics (namespace = "ServerlessAirline" , service = "payment" , captureColdStart = true )
20
+ public void handleRequest (InputStream input , OutputStream output , Context context ) throws IOException {
21
+ Map map = mapper .readValue (input , Map .class );
22
+
23
+ System .out .println (map .size ());
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,23 @@ Resources:
34
34
Path : /hello
35
35
Method : get
36
36
37
+ HelloWorldStreamFunction :
38
+ Type : AWS::Serverless::Function
39
+ Properties :
40
+ CodeUri : HelloWorldFunction
41
+ Handler : helloworld.AppStream::handleRequest
42
+ MemorySize : 512
43
+ Tracing : Active
44
+ Environment :
45
+ Variables :
46
+ POWERTOOLS_LOGGER_SAMPLE_RATE : 0.7
47
+ Events :
48
+ HelloWorld :
49
+ Type : Api
50
+ Properties :
51
+ Path : /hellostream
52
+ Method : get
53
+
37
54
Outputs :
38
55
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
39
56
# Find out more about other implicit resources you can reference within SAM
You can’t perform that action at this time.
0 commit comments