1"use strict";(self.webpackChunkjreact_com_docsaurus_01=self.webpackChunkjreact_com_docsaurus_01||[]).push([[150],{4365:(e,n,t)=>{t.d(n,{W:()=>c});var r=t(6540),a=t(502);const l=["zero","one","two","few","many","other"];function s(e){return l.filter((n=>e.includes(n)))}const i={locale:"en",pluralForms:s(["one","other"]),select:e=>1===e?"one":"other"};function o(){const{i18n:{currentLocale:e}}=(0,a.A)();return(0,r.useMemo)((()=>{try{return function(e){const n=new Intl.PluralRules(e);return{locale:e,pluralForms:s(n.resolvedOptions().pluralCategories),select:e=>n.select(e)}}(e)}catch(n){return console.error(`Failed to use Intl.PluralRules for locale "${e}".\nDocusaurus will fallback to the default (English) implementation.\nError: ${n.message}\n`),i}}),[e])}function c(){const e=o();return{selectMessage:(n,t)=>function(e,n,t){const r=e.split("|");if(1===r.length)return r[0];r.length>t.pluralForms.length&&console.error(`For locale=${t.locale}, a maximum of ${t.pluralForms.length} plural forms are expected (${t.pluralForms.join(",")}), but the message contains ${r.length}: ${e}`);const a=t.select(n),l=t.pluralForms.indexOf(a);return r[Math.min(l,r.length-1)]}(t,n,e)}}},6690:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>r,toc:()=>u});const r=JSON.parse('{"id":"aws/aws-lambda/examples/lamdba-handler","title":"Lambda Handler","description":"(example)","source":"@site/docs/aws/aws-lambda/examples/lamdba-handler.mdx","sourceDirName":"aws/aws-lambda/examples","slug":"/aws/aws-lambda/examples/lamdba-handler","permalink":"/docs/aws/aws-lambda/examples/lamdba-handler","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":10,"frontMatter":{"sidebar_position":10},"sidebar":"tutorialSidebar","previous":{"title":"Examples","permalink":"/docs/aws/aws-lambda/examples"},"next":{"title":"The First Lambda Example","permalink":"/docs/aws/aws-lambda/examples/first-aws-lambda-example"}}');var a=t(4848),l=t(8453),s=t(7170),i=t(3304);const o={sidebar_position:10},c="Lambda Handler",d={},u=[{value:"<em><strong>(example)</strong></em>",id:"example",level:2},{value:"Create Handler",id:"create-handler",level:3},{value:"Custom <em><strong>MethodHandler</strong></em>",id:"custom-methodhandler",level:4},{value:"<em><strong>RequestHandler</strong></em> Interface",id:"requesthandler-interface",level:4},{value:"<em><strong>RequestStreamHandler</strong></em> Interface",id:"requeststreamhandler-interface",level:4},{value:"Deployment File",id:"deployment-file",level:3},{value:"Build Deployment File",id:"build-deployment-file",level:3}];function m(e){const n={code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",hr:"hr",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"lambda-handler",children:"Lambda Handler"})}),"\n",(0,a.jsx)(n.h2,{id:"example",children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.strong,{children:"(example)"})})}),"\n",(0,a.jsx)(n.h3,{id:"create-handler",children:"Create Handler"}),"\n",(0,a.jsx)(n.p,{children:"There are three ways of creating a handler:"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:"Creating a custom MethodHandler"}),"\n",(0,a.jsx)(n.li,{children:"Implementing the RequestHandler interface"}),"\n",(0,a.jsx)(n.li,{children:"Implementing the RequestStreamHandler interface"}),"\n"]}),"\n",(0,a.jsxs)(n.h4,{id:"custom-methodhandler",children:["Custom ",(0,a.jsx)(n.em,{children:(0,a.jsx)(n.strong,{children:"MethodHandler"})})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-java",children:'public class LambdaMethodHandler {\n public String handleRequest(String input, Context context) {\n context.getLogger().log("Input: " + input);\n return "Hello World - " + input;\n }\n}\n'})}),"\n",(0,a.jsxs)(n.h4,{id:"requesthandler-interface",children:[(0,a.jsx)(n.em,{children:(0,a.jsx)(n.strong,{children:"RequestHandler"})})," Interface"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-java",children:'public class LambdaRequestHandler\n implements RequestHandler<String, String> {\n public String handleRequest(String input, Context context) {\n context.getLogger().log("Input: " + input);\n return "Hello World - " + input;\n }\n}\n'})}),"\n",(0,a.jsxs)(n.h4,{id:"requeststreamhandler-interface",children:[(0,a.jsx)(n.em,{children:(0,a.jsx)(n.strong,{children:"RequestStreamHandler"})})," Interface"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-java",children:'public class LambdaRequestStreamHandler\n implements RequestStreamHandler {\n public void handleRequest(InputStream inputStream,\n OutputStream outputStream, Context context) {\n String input = IOUtils.toString(inputStream, "UTF-8");\n outputStream.write(("Hello World - " + input).getBytes());\n }\n}\n'})}),"\n",(0,a.jsx)(n.h3,{id:"deployment-file",children:"Deployment File"}),"\n",(0,a.jsx)(n.p,{children:"pom.xml"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-java",children:'<?xml version="1.0" encoding="UTF-8"?>\n<project xmlns="http://maven.apache.org/POM/4.0.0"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n <modelVersion>4.0.0</modelVersion>\n\n <groupId>zjc.examples</groupId>\n <artifactId>lambda-hello-world</artifactId>\n <version>
11.0-SNAPSHOT</version>\n\n <properties>\n <maven.compiler.source>21</maven.compiler.source>\n <maven.compiler.target>21</maven.compiler.target>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n </properties>\n\n <dependencies>\n <dependency>\n <groupId>com.amazonaws</groupId>\n <artifactId>aws-lambda-java-core</artifactId>\n <version>1.2.0</version>\n </dependency>\n </dependencies>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-shade-plugin</artifactId>\n <version>3.2.1</version>\n <configuration>\n <createDependencyReducedPom>false</createDependencyReducedPom>\n </configuration>\n <executions>\n <execution>\n <phase>package</phase>\n <goals>\n <goal>shade</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n</project>\n'})}),"\n",(0,a.jsx)(n.h3,{id:"build-deployment-file",children:"Build Deployment File"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-java",children:"mvn clean package\n"})}),"\n",(0,a.jsx)(n.hr,{}),"\n",(0,a.jsx)("br",{}),"\n",(0,a.jsx)("br",{}),"\n","\n",(0,a.jsx)(s.A,{items:(0,i.$S)().items})]})}function p(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(m,{...e})}):m(e)}},7170:(e,n,t)=>{t.d(n,{A:()=>j});t(6540);var r=t(4164),a=t(7936),l=t(7634),s=t(4365),i=t(5242),o=t(9979),c=t(4861);const d={cardContainer:"cardContainer_fWXF",cardTitle:"cardTitle_rnsV",cardDescription:"cardDescription_PWke"};var u=t(4848);function m(e){let{href:n,children:t}=e;return(0,u.jsx)(l.A,{href:n,className:(0,r.A)("card padding--lg",d.cardContainer),children:t})}function p(e){let{href:n,icon:t,title:a,description:l}=e;return(0,u.jsxs)(m,{href:n,children:[(0,u.jsxs)(c.A,{as:"h2",className:(0,r.A)("text--truncate",d.cardTitle),title:a,children:[t," ",a]}),l&&(0,u.jsx)("p",{className:(0,r.A)("text--truncate",d.cardDescription),title:l,children:l})]})}function h(e){let{item:n}=e;const t=(0,a.Nr)(n),r=function(){const{selectMessage:e}=(0,s.W)();return n=>e(n,(0,o.T)({message:"1 item|{count} items",id:"theme.docs.DocCard.categoryDescription.plurals",description:"The default description for a category card in the generated index about how many items this category includes"},{count:n}))}();return t?(0,u.jsx)(p,{href:t,icon:"\ud83d\uddc3\ufe0f",title:n.label,description:n.description??r(n.items.length)}):null}function g(e){let{item:n}=e;const t=(0,i.A)(n.href)?"\ud83d\udcc4\ufe0f":"\ud83d\udd17",r=(0,a.cC)(n.docId??void 0);return(0,u.jsx)(p,{href:n.href,icon:t,title:n.label,description:n.description??r?.description})}function x(e){let{item:n}=e;switch(n.type){case"link":return(0,u.jsx)(g,{item:n});case"category":return(0,u.jsx)(h,{item:n});default:throw new Error(`unknown item type ${JSON.stringify(n)}`)}}function f(e){let{className:n}=e;const t=(0,a.$S)();return(0,u.jsx)(j,{items:t.items,className:n})}function j(e){const{items:n,className:t}=e;if(!n)return(0,u.jsx)(f,{...e});const l=(0,a.d1)(n);return(0,u.jsx)("section",{className:(0,r.A)("row",t),children:l.map(((e,n)=>(0,u.jsx)("article",{className:"col col--6 margin-bottom--lg",children:(0,u.jsx)(x,{item:e})},n)))})}},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>i});var r=t(6540);const a={},l=r.createContext(a);function s(e){const n=r.useContext(l);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),r.createElement(l.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.