第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

aws lambda 是否只能公開(kāi)一個(gè) spring boot api

aws lambda 是否只能公開(kāi)一個(gè) spring boot api

qq_花開(kāi)花謝_0 2021-09-03 14:33:18
我已經(jīng)使用 Spring Boot 開(kāi)發(fā)了 4 個(gè) api。現(xiàn)在我正在嘗試為無(wú)服務(wù)器啟用 aws lambda。是否可以使用單個(gè) lambda 公開(kāi) 4 個(gè) api。
查看完整描述

1 回答

?
慕俠2389804

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊

是否可以使用單個(gè) lambda 公開(kāi) 4 個(gè) api。

AWS lambda 是FaaS- 函數(shù)即服務(wù),每個(gè) Lambda 一個(gè)函數(shù)。

但是,您可以使用包裝器/代理函數(shù)作為入口點(diǎn)來(lái)實(shí)現(xiàn)預(yù)期的功能,并根據(jù)需要將請(qǐng)求路由到上游方法/函數(shù)

它在這里描述aws api gateway & lambda: multiple endpoint/functions vs single endpoint

http://img1.sycdn.imooc.com//6131c1ea000197fb12580710.jpg

查看以下有關(guān)創(chuàng)建 API 網(wǎng)關(guān) => Lambda 代理集成的文檔:http : //docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html


以下只是對(duì)aws api gateway & lambda: multiple endpoint/functions vs single endpoint 中給出的內(nèi)容的重新措辭解釋。


AWS 例子有很好的解釋?zhuān)蝗缦滤镜?Lambda 請(qǐng)求:


POST /testStage/hello/world?name=me HTTP/1.1

Host: gy415nuibc.execute-api.us-east-1.amazonaws.com

Content-Type: application/json

headerName: headerValue


{

    "a": 1

}

最終將向您的 AWS Lambda 函數(shù)發(fā)送以下事件數(shù)據(jù):


{

  "message": "Hello me!",

  "input": {

    "resource": "/{proxy+}",

    "path": "/hello/world",

    "httpMethod": "POST",

    "headers": {

      "Accept": "*/*",

      "Accept-Encoding": "gzip, deflate",

      "cache-control": "no-cache",

      "CloudFront-Forwarded-Proto": "https",

      "CloudFront-Is-Desktop-Viewer": "true",

      "CloudFront-Is-Mobile-Viewer": "false",

      "CloudFront-Is-SmartTV-Viewer": "false",

      "CloudFront-Is-Tablet-Viewer": "false",

      "CloudFront-Viewer-Country": "US",

      "Content-Type": "application/json",

      "headerName": "headerValue",

      "Host": "gy415nuibc.execute-api.us-east-1.amazonaws.com",

      "Postman-Token": "9f583ef0-ed83-4a38-aef3-eb9ce3f7a57f",

      "User-Agent": "PostmanRuntime/2.4.5",

      "Via": "1.1 d98420743a69852491bbdea73f7680bd.cloudfront.net (CloudFront)",

      "X-Amz-Cf-Id": "pn-PWIJc6thYnZm5P0NMgOUglL1DYtl0gdeJky8tqsg8iS_sgsKD1A==",

      "X-Forwarded-For": "54.240.196.186, 54.182.214.83",

      "X-Forwarded-Port": "443",

      "X-Forwarded-Proto": "https"

    },

    "queryStringParameters": {

      "name": "me"

    },

    "pathParameters": {

      "proxy": "hello/world"

    },

    "stageVariables": {

      "stageVariableName": "stageVariableValue"

    },

    "requestContext": {

      "accountId": "12345678912",

      "resourceId": "roq9wj",

      "stage": "testStage",

      "requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",

      "identity": {

        "cognitoIdentityPoolId": null,

        "accountId": null,

        "cognitoIdentityId": null,

        "caller": null,

        "apiKey": null,

        "sourceIp": "192.168.196.186",

        "cognitoAuthenticationType": null,

        "cognitoAuthenticationProvider": null,

        "userArn": null,

        "userAgent": "PostmanRuntime/2.4.5",

        "user": null

      },

      "resourcePath": "/{proxy+}",

      "httpMethod": "POST",

      "apiId": "gy415nuibc"

    },

    "body": "{\r\n\t\"a\": 1\r\n}",

    "isBase64Encoded": false

  }

}

現(xiàn)在您可以訪問(wèn)所有標(biāo)頭、url 參數(shù)、正文等。因此,您可以使用它在包裝器/代理 Lambda 函數(shù)中以不同方式處理請(qǐng)求,并根據(jù)您的路由需求路由到上游函數(shù)。


今天很多人都在使用這種方法,而不是為每個(gè)方法和 api 網(wǎng)關(guān)資源創(chuàng)建 lambda 函數(shù)。


這種方法有利有弊


部署:如果每個(gè) lambda 函數(shù)都是離散的,那么您可以獨(dú)立部署它們,這可能會(huì)降低代碼更改的風(fēng)險(xiǎn)(微服務(wù)策略)。相反,您可能會(huì)發(fā)現(xiàn)需要單獨(dú)部署功能會(huì)增加復(fù)雜性和負(fù)擔(dān)。

自我描述:API Gateway 的界面讓您可以非常直觀地查看 RESTful 端點(diǎn)的布局——名詞和動(dòng)詞都一目了然。實(shí)現(xiàn)您自己的路由可能會(huì)以這種可見(jiàn)性為代價(jià)。

Lambda 大小和限制:如果您代理所有——那么您最終需要選擇一個(gè)實(shí)例大小、超時(shí)等,以適應(yīng)您的所有 RESTful 端點(diǎn)。如果您創(chuàng)建離散函數(shù),那么您可以更仔細(xì)地選擇最能滿(mǎn)足特定調(diào)用需求的內(nèi)存占用、超時(shí)、死信行為等。

更多關(guān)于Monolithic lambdavsMicro Lambda在這里:https : //hackernoon.com/aws-lambda-should-you-have-few-monolithic-functions-or-many-single-purposed-functions-8c3872d4338f


查看完整回答
反對(duì) 回復(fù) 2021-09-03
  • 1 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)