|
| 1 | +/* |
| 2 | + * Copyright 2023 Amazon.com, Inc. or its affiliates. |
| 3 | + * Licensed under the Apache License, Version 2.0 (the |
| 4 | + * "License"); you may not use this file except in compliance |
| 5 | + * with the License. You may obtain a copy of the License at |
| 6 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | + * Unless required by applicable law or agreed to in writing, software |
| 8 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | + * See the License for the specific language governing permissions and |
| 11 | + * limitations under the License. |
| 12 | + * |
| 13 | + */ |
| 14 | + |
| 15 | +package helloworld; |
| 16 | + |
| 17 | +import com.amazonaws.services.lambda.runtime.Context; |
| 18 | +import com.amazonaws.services.lambda.runtime.RequestStreamHandler; |
| 19 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 20 | +import java.io.IOException; |
| 21 | +import java.io.InputStream; |
| 22 | +import java.io.OutputStream; |
| 23 | +import java.util.Map; |
| 24 | +import software.amazon.lambda.powertools.logging.Logging; |
| 25 | +import software.amazon.lambda.powertools.metrics.Metrics; |
| 26 | + |
| 27 | +public class AppStream implements RequestStreamHandler { |
| 28 | + private static final ObjectMapper mapper = new ObjectMapper(); |
| 29 | + |
| 30 | + @Override |
| 31 | + @Logging(logEvent = true) |
| 32 | + @Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true) |
| 33 | + public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { |
| 34 | + Map map = mapper.readValue(input, Map.class); |
| 35 | + |
| 36 | + System.out.println(map.size()); |
| 37 | + } |
| 38 | +} |
0 commit comments