中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

新電商平臺(tái)seo整站優(yōu)化吧

新電商平臺(tái),seo整站優(yōu)化吧,哪個(gè)網(wǎng)站做分享賺傭金,廣州網(wǎng)站建設(shè) 駿域網(wǎng)站建設(shè)專家AWS API Gateway 集成使得使用符合 OpenAPI 標(biāo)準(zhǔn)的 Lambda Function 輕松實(shí)現(xiàn) REST API。 關(guān)于開放API 它是一個(gè) 允許以標(biāo)準(zhǔn)方式描述 REST API 的規(guī)范。 OpenAPI規(guī)范 (OAS) 為 REST API 定義了與編程語言無關(guān)的標(biāo)準(zhǔn)接口描述。這使得人類和計(jì)算機(jī)都可以發(fā)現(xiàn)和理解服務(wù)的功能&am…

AWS API Gateway 集成使得使用符合 OpenAPI 標(biāo)準(zhǔn)的 Lambda Function 輕松實(shí)現(xiàn) REST API。

關(guān)于開放API

????????它是一個(gè)?允許以標(biāo)準(zhǔn)方式描述 REST API 的規(guī)范。?OpenAPI規(guī)范 (OAS) 為 REST API 定義了與編程語言無關(guān)的標(biāo)準(zhǔn)接口描述。這使得人類和計(jì)算機(jī)都可以發(fā)現(xiàn)和理解服務(wù)的功能,而無需訪問源代碼、附加文檔或檢查網(wǎng)絡(luò)流量。

關(guān)于Swagger

????????Swagger是一組圍繞 OpenAPI 規(guī)范構(gòu)建的開源工具,可以幫助軟件專業(yè)人員設(shè)計(jì)、構(gòu)建、記錄和使用 REST API。OpenAPI 處理規(guī)范,Swagger 實(shí)現(xiàn)規(guī)范來描述 REST API 。

OpenAPI規(guī)范簡介

目的

  • API是使用OpenAPI標(biāo)準(zhǔn)定義的,可以被人類和計(jì)算機(jī)發(fā)現(xiàn),無需訪問源代碼、文檔或通過網(wǎng)絡(luò)流量檢查即可了解服務(wù)的功能。?
  • 如果定義正確,消費(fèi)者可以使用最少量的實(shí)現(xiàn)邏輯來理解遠(yuǎn)程服務(wù)并與之交互。
  • 然后,文檔生成工具可以使用 OpenAPI 定義來顯示 API,代碼生成工具可以使用各種編程語言、測試工具和許多其他用例來生成服務(wù)器和客戶端。

開放API的主要?概念

OpenAPI文檔

定義/描述 API 的文檔(或一組文檔)。OpenAPI 定義使用并符合 OpenAPI 規(guī)范。?

路徑模板

路徑模板是指使用由大括號(hào) ({}) 分隔的模板表達(dá)式,將 URL 路徑的一部分標(biāo)記為可使用路徑參數(shù)進(jìn)行替換。

路徑中的每個(gè)模板表達(dá)式必須對應(yīng)于路徑項(xiàng)本身和/或路徑項(xiàng)的每個(gè)操作中包含的路徑參數(shù)。

媒體類型

媒體類型定義分布在多個(gè)資源中。媒體類型定義應(yīng)符合RFC6838。

可能的媒體類型定義的一些示例:

  • 應(yīng)用程序/json
  • 測試/普通;chartset-uff-8

HTTP 狀態(tài)代碼

HTTP 狀態(tài)代碼用于指示已執(zhí)行操作的狀態(tài)??捎玫臓顟B(tài)代碼由RFC7231定義,注冊的狀態(tài)代碼列在IANA 狀態(tài)代碼注冊表中。

AWS Lambda 函數(shù)的開放 API 參考實(shí)現(xiàn)?

參考架構(gòu)

?

參考實(shí)現(xiàn)由以下組件組成:

  • AWS Lambda函數(shù)實(shí)現(xiàn)業(yè)務(wù)需求/邏輯?
  • API 網(wǎng)關(guān)將功能公開為 API
  • Amazon API 網(wǎng)關(guān)集成器,用于集成開放 API 規(guī)范并將 Lambda 函數(shù)操作公開為 API

有關(guān)每個(gè)架構(gòu)組件的更多詳細(xì)信息,請參閱后續(xù)部分。

關(guān)于 AWS Lambda 函數(shù)

Lambda 是一種計(jì)算服務(wù),允許在不配置或管理服務(wù)器的情況下運(yùn)行代碼。Lambda 在高可用性計(jì)算基礎(chǔ)設(shè)施上運(yùn)行代碼,并執(zhí)行計(jì)算資源的所有管理,包括服務(wù)器和操作系統(tǒng)維護(hù)、容量配置和自動(dòng)擴(kuò)展以及日志記錄。使用 Lambda,幾乎可以為任何類型的應(yīng)用程序或后端服務(wù)運(yùn)行代碼。它所需要的只是以Lambda 支持的語言之一提供代碼。
Lambda 僅在需要時(shí)運(yùn)行函數(shù)并自動(dòng)擴(kuò)展,從每天幾個(gè)請求到每秒數(shù)千個(gè)請求。它節(jié)省了計(jì)算成本,因?yàn)橹恍柚Ц逗瘮?shù)在運(yùn)行時(shí)消耗的計(jì)算時(shí)間——代碼不運(yùn)行時(shí)不收費(fèi)??梢允褂?Lambda API 或來自其他 AWS 服務(wù)的事件調(diào)用 lambda 函數(shù),例如在 S3 存儲(chǔ)桶中創(chuàng)建對象時(shí)。

關(guān)于 AWS API 網(wǎng)關(guān)?

Amazon API Gateway 是一項(xiàng)完全托管的服務(wù),使開發(fā)人員可以輕松創(chuàng)建、發(fā)布、維護(hù)、監(jiān)控和保護(hù)任何規(guī)模的 API。API 充當(dāng)應(yīng)用程序從后端服務(wù)訪問數(shù)據(jù)、業(yè)務(wù)邏輯或功能的“前門”。

關(guān)于AWS API集成功能

這種類型的集成允許 API 公開 AWS 服務(wù)操作。在AWS集成中,需要配置集成請求和集成響應(yīng),并設(shè)置從方法請求到集成請求、從集成響應(yīng)到方法響應(yīng)的必要數(shù)據(jù)映射。

它允許指定用于此方法的后端集成的詳細(xì)信息。此擴(kuò)展是OpenAPI 操作對象的擴(kuò)展屬性。結(jié)果是一個(gè)API 網(wǎng)關(guān)集成對象。

重要財(cái)產(chǎn)

與指定后??端的集成類型。有效值為:

  • http 或 http_proxy,用于與 HTTP 后端集成。
  • aws_proxy,用于與 AWS Lambda 函數(shù)的代理集成?
  • aws,用于與 AWS Lambda 函數(shù)自定義集成,或與其他 AWS 服務(wù)集成,例如 Amazon DynamoDB、Amazon Simple notification Service 或 Amazon Simple Queue Service。
  • mock,用于與 API Gateway 集成,無需調(diào)用任何后端。這種類型的集成允許 API Gateway 返回響應(yīng),而無需將請求進(jìn)一步發(fā)送到后端。

Lambda 代理集成支持單個(gè) Lambda 函數(shù)的簡化集成設(shè)置。設(shè)置很簡單,可以隨后端一起發(fā)展,而無需拆除已經(jīng)創(chuàng)建的設(shè)置。由于這些原因,強(qiáng)烈建議與 Lambda 函數(shù)集成。

相比之下,Lambda 自定義集成允許為具有類似輸入和輸出數(shù)據(jù)格式要求的各種集成端點(diǎn)重用已配置的映射模板。該設(shè)置涉及較多,推薦用于更高級(jí)的應(yīng)用場景。

x-amazon-apigateway-integrations例子

以下示例使用 OpenAPI 標(biāo)準(zhǔn)定義 HTTP API(一個(gè) GET 和一個(gè) POST),并為每個(gè) API 使用一個(gè) API 網(wǎng)關(guān)集成來與 Lambda Function 集成(通過引用函數(shù)的 ARN)。它使用 AWS Identity and Access Management (IAM) 角色作為集成憑證。以下格式采用 YAML。?

openapi: 3.0.1
info:description: "This is a definition of Proxy Pattern Service. The service has 2 APIs."version: v1title: "Proxy Pattern Service"
paths:/v1/proxypattern/employee:options:summary: CORS supportdescription: |Enable CORS by returning correct headersconsumes:- application/jsonproduces:- application/jsontags:- CORSsecurity:- NONE: []x-amazon-apigateway-integration:type: mockrequestTemplates:application/json: |{"statusCode" : 200}responses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Headers : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,x-apigw-api-id,X-Amz-Security-Token,Cache-Control'"method.response.header.Access-Control-Allow-Methods : "'*'"method.response.header.Access-Control-Allow-Origin : "'*'"responseTemplates:application/json: |{}responses:200:description: Default response for CORS methodheaders:Access-Control-Allow-Headers:type: "string"Access-Control-Allow-Methods:type: "string"Access-Control-Allow-Origin:type: "string"post:summary: "Save Employee"operationId: "saveemployees"tags:- saveemployeesrequestBody:required: truecontent:application/json:schema:$ref: '#/components/schemas/employee'responses:'200':description: "Saved Employee Successfully"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: "#/components/schemas/employee"'400':description: "Application Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse''500':description: "Other unspecified Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse'x-amazon-apigateway-integration:credentials:Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-rolehttpMethod: "POST"uri:Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ProxyPatternService.Arn}:live/invocationsresponses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""BAD.*":statusCode: "400"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""INT.*":statusCode: "500"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'"type: "aws_proxy"get:summary: "Get All the Employees"operationId: "getemployees"tags:- getemployeesresponses:'200':description: "All The Employees retrieved successfully"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:type: "array"items:$ref: "#/components/schemas/employee"'204':description: "Employees not found"headers:Access-Control-Allow-Origin:schema:type: "string"'500':description: "Other unspecified Errors"headers:Access-Control-Allow-Origin:schema:type: "string"content:application/json:schema:$ref: '#/components/schemas/ErrorResponse'x-amazon-apigateway-integration:credentials:Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-rolehttpMethod: "POST"uri:Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ProxyPatternService.Arn}:live/invocationsresponses:"default":statusCode: "200"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""BAD.*":statusCode: "204"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'""INT.*":statusCode: "500"responseParameters:method.response.header.Access-Control-Allow-Origin : "'*'"type: "aws_proxy"components:schemas:Employee:type: objectdescription: EMPLOYEEproperties:employeeId:type: stringdescription: Id of the EmployeeemployeeName:type: stringdescription: Name of the Employeerequired:- employeeIdErrorResponse:type: "object"properties:errorCode:type: stringdescription: |indicates an error in processing.XXXX - Error in saving messageerrorMessage:type: stringdescription: "message description of error."

以下是 AWS Lambda 函數(shù)的云形成模板,該模板將通過 AWS API Gateway 公開。格式為 YAML。此處,已引用OpenAPI定義/openapi-apigateway-PxyPtrnSvc.yaml文件 ( ),以便API Gateway了解通過 OpenAPI 定義文件定義的集成點(diǎn)。

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Serverless Quarkus HTTP - Proxy Pattern Poc Service
Globals:Api:EndpointConfiguration:Type: PRIVATEAuth:ResourcePolicy:CustomStatements: {Effect: 'Allow',Action: 'execute-api:Invoke',Resource: ['execute-api:/*/*/*'],Principal: '*'}
Resources:ProxyPatternServiceAWSApiGateway:Type: AWS::Serverless::ApiProperties:TracingEnabled: trueName: ProxyPatternServiceSvcApiGatewayStageName: devDefinitionBody:'Fn::Transform':Name: 'AWS::Include'Parameters:Location: './openapi-apigateway-PxyPtrnSvc.yaml'ProxyPatternServiceLogGroup:Type: AWS::Logs::LogGroupProperties:LogGroupName: '/aws/lambda/ProxyPatternService'RetentionInDays: 30ProxyPatternService:Type: AWS::Serverless::FunctionProperties:Handler: not.used.in.provided.runtimeRuntime: providedCodeUri: component1/function.zipMemorySize: 512Timeout: 900FunctionName: ProxyPatternServiceEnvironment:Variables:LOG_LEVEL: INFODISABLE_SIGNAL_HANDLERS: trueRole: !Sub "arn:aws:iam::${AWS::AccountId}:role/delegate-admin-lambda-proxy-pattern-role"Tracing: Active
Outputs:ProxyPatternServiceAWSApiGateway:Description: 'API Gateway endpoint URL for dev stage for Proxy Pattern Service Template'Value: !Sub 'https://${ProxyPatternServiceAWSApiGateway}.execute-api.${AWS::Region}.amazonaws.com/dev/'ProxyPatternServiceAWSApiGatewayRestApiId:Description: 'API Gateway ARN for Basic AWS API Gateway'Value: !Ref ProxyPatternServiceAWSApiGatewayExport:Name: ProxyPatternServiceAWSApiGateway-RestApiIdProxyPatternServiceAWSApiGatewayRootResourceId:Value: !GetAtt ProxyPatternServiceAWSApiGateway.RootResourceIdExport:Name: ProxyPatternServiceAWSApiGateway-RootResourceId

示例 API 定義可以與以下使用 Java 的 Controller 接口相關(guān),并且可以在 Java Quarkus 中實(shí)現(xiàn):

package com.example.proxypattern.controller;import com.example.proxypattern.exception.model.ErrorResponse;
import com.example.proxypattern.model.Employee;import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;@Path("v1/proxypattern/")
public interface IProxyPatternController {@GET@Path("/employee")@Produces(MediaType.APPLICATION_JSON)@Operation(summary = "Get All the Employees", description = "getEmployees")@APIResponses(value = {@APIResponse(responseCode = "204", description = "Employees not found"),@APIResponse(responseCode = "200", description = "All The Employees retrieved successfully", content = @Content(schema = @Schema(implementation = Employee.class))),@APIResponse(responseCode = "500", description = "Other unspecified Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })public Response getAllEmployee();@POST@Path("/employee")@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)@Operation(summary = "Save Employee", description = "saveEmployees")@APIResponses(value = {@APIResponse(responseCode = "400", description = "Application Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),@APIResponse(responseCode = "200", description = "Saved Employee Successfully", content = @Content(schema = @Schema(implementation = Employee.class))),@APIResponse(responseCode = "500", description = "Other unspecified Errors", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })public Response saveEmployee(Employee employee);
}

實(shí)現(xiàn)語言可能有所不同。如果技術(shù)決策是使用Java作為編碼語言,則可以選擇Java Quarkus作為Lambda函數(shù)的實(shí)現(xiàn)語言。Lambda 支持自定義運(yùn)行時(shí),因此可以本地構(gòu)建 Quarkus 代碼來解決與 Lambda 冷啟動(dòng)相關(guān)的響應(yīng)時(shí)間問題。

控制器實(shí)現(xiàn)代碼如下所示。這里,業(yè)務(wù)邏輯已通過業(yè)務(wù)服務(wù)類進(jìn)行抽象:

package com.example.proxypattern.controller.impl;import com.example.proxypattern.controller.IProxyPatternController;
import com.example.proxypattern.model.Employee;
import com.example.proxypattern.service.impl.EmployeeServiceImpl;import lombok.extern.slf4j.Slf4j;
import org.eclipse.microprofile.opentracing.Traced;import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.Response;import java.util.List;@Slf4j
@Traced
@Singleton
public class ProxyPatternControllerImpl implements IProxyPatternController {@InjectEmployeeServiceImpl employeeService;@Overridepublic Response getAllEmployee() {Response.Status status = Response.Status.OK;//The business logic is abstracted here in Service codeList<Employee> listOfEmployee = employeeService.getAllEmployee();if(listOfEmployee.isEmpty()){status = Response.Status.NO_CONTENT;}log.info("Sending employee {}", listOfEmployee);return Response.status(status).entity(listOfEmployee).build();}@Overridepublic Response saveEmployee(Employee employee) {//The business logic is abstracted here in Service codeEmployee employeeResponse = employeeService.saveEmployee(employee);return Response.status(Response.Status.CREATED).entity(employeeResponse).build();}
}

可以使用Maven來構(gòu)建項(xiàng)目,也可以使用以下依賴來構(gòu)建項(xiàng)目:


<dependencies><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-resteasy</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-amazon-lambda-rest</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-openapi</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-resteasy-jackson</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-logging-json</artifactId></dependency><dependency><groupId>org.jboss.slf4j</groupId><artifactId>slf4j-jboss-logmanager</artifactId></dependency><dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.2</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-annotations</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-hibernate-validator</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-opentracing</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-smallrye-health</artifactId></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-junit5</artifactId><scope>test</scope></dependency><dependency><groupId>io.rest-assured</groupId><artifactId>rest-assured</artifactId><scope>test</scope></dependency><dependency><groupId>io.quarkus</groupId><artifactId>quarkus-junit5-mockito</artifactId><scope>test</scope></dependency><dependency><groupId>org.jacoco</groupId><artifactId>org.jacoco.agent</artifactId><classifier>runtime</classifier><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.20</version><scope>provided</scope></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency></dependencies>

結(jié)論

AWS API Gateway 集成可以輕松使用 Lambda Function 實(shí)現(xiàn) REST API,該函數(shù)符合 OpenAPI 標(biāo)準(zhǔn),并且可以輕松與 AWS API Gateway 集成。

http://www.risenshineclean.com/news/22454.html

相關(guān)文章:

  • wordpress 插件被墻免費(fèi)seo工具
  • 蘇州疫情最新政策seo外鏈資源
  • 淄博張店網(wǎng)站排名優(yōu)化怎么自己做一個(gè)網(wǎng)頁
  • 鷹潭做網(wǎng)站自己怎么做網(wǎng)站優(yōu)化
  • 南昌網(wǎng)站seo技術(shù)廠家如何做公司網(wǎng)站推廣
  • dedecms建手機(jī)網(wǎng)站游戲推廣是什么工作
  • 北京本地服務(wù)信息網(wǎng)西安seo站內(nèi)優(yōu)化
  • 永興縣網(wǎng)站建設(shè)公司哪家好湖人最新排名最新排名
  • 網(wǎng)站建設(shè)怎么記賬手機(jī)關(guān)鍵詞點(diǎn)擊排名軟件
  • 網(wǎng)站建設(shè)相關(guān)資料整理的重要性seo快排技術(shù)教程
  • nginx即代理又做網(wǎng)站競價(jià)托管哪家效果好
  • 國內(nèi)大型php網(wǎng)站建設(shè)線上銷售如何找到精準(zhǔn)客戶
  • 順德外貿(mào)網(wǎng)站建設(shè)2024年新冠疫情最新消息今天
  • 網(wǎng)站收錄了怎么做排名百度關(guān)鍵詞是怎么排名靠前
  • 網(wǎng)站的外鏈怎么做免費(fèi)刷seo
  • b2c的電子信息網(wǎng)站系統(tǒng)清理優(yōu)化工具
  • 泉州制作網(wǎng)站開發(fā)搜索引擎環(huán)境優(yōu)化
  • 企業(yè)網(wǎng)站建設(shè)和實(shí)現(xiàn) 論文關(guān)鍵詞推廣怎么做
  • 西京一師一優(yōu)課建設(shè)網(wǎng)站深圳優(yōu)化排名公司
  • 福州免費(fèi)企業(yè)網(wǎng)站建站更先進(jìn)的seo服務(wù)
  • 網(wǎng)站建設(shè)主題與建設(shè)目標(biāo)最火網(wǎng)站排名
  • 濱城區(qū)住房和城鄉(xiāng)建設(shè)局網(wǎng)站seo優(yōu)化的優(yōu)點(diǎn)
  • 透視圖在什么網(wǎng)站上可以做企業(yè)網(wǎng)站設(shè)計(jì)欣賞
  • 北京個(gè)人網(wǎng)站建設(shè)多少錢西安市seo排名按天優(yōu)化
  • 交流網(wǎng)站建設(shè)心得體會(huì)百度指數(shù)查詢?nèi)肟?/a>
  • 交互動(dòng)效庫 網(wǎng)站晨陽seo顧問
  • 網(wǎng)站 建設(shè)制作菜鳥教程建網(wǎng)站的流程
  • 金融做網(wǎng)站百度瀏覽器網(wǎng)頁
  • 日本人做爰過程網(wǎng)站南寧網(wǎng)站seo排名優(yōu)化
  • 揚(yáng)州學(xué)做網(wǎng)站培訓(xùn)多少錢軟件開發(fā)公司推薦