classEchoRequest(messages.Message):message=messages.StringField(1)classEchoResponse(messages.Message):"""A proto Message that contains a simple string field."""message=messages.StringField(1)ECHO_RESOURCE=endpoints.ResourceContainer(EchoRequest,n=messages.IntegerField(2,default=1))
請注意,如果要求主體中未顯示引數 (例如在 GET 要求中),您可以省略要求的 Message 類別,只使用 message_types.VoidMessage 值。
@endpoints.method(# This method takes a ResourceContainer defined above.ECHO_RESOURCE,# This method returns an Echo message.EchoResponse,path="echo",http_method="POST",name="echo",)defecho(self,request):
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-18 (世界標準時間)。"],[[["\u003cp\u003eAn API is an RPC service with remote methods accessible to external clients, requiring a service class that subclasses \u003ccode\u003eremote.Service\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach API method needs \u003ccode\u003eMessage\u003c/code\u003e classes defined for both incoming requests and outgoing responses to properly map data, though these \u003ccode\u003eMessage\u003c/code\u003e classes are not part of the exposed API.\u003c/p\u003e\n"],["\u003cp\u003eIf requests have path or query string arguments, a \u003ccode\u003eResourceContainer\u003c/code\u003e class should be used instead of a simple \u003ccode\u003eMessage\u003c/code\u003e class for data mapping.\u003c/p\u003e\n"],["\u003cp\u003eTo create an API, you must decorate a subclass of \u003ccode\u003eremote.Service\u003c/code\u003e with \u003ccode\u003e@endpoints.api\u003c/code\u003e, define \u003ccode\u003eMessage\u003c/code\u003e or \u003ccode\u003eResourceContainer\u003c/code\u003e classes for requests and responses, and decorate the method with \u003ccode\u003e@endpoints.method\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe API's name and version, specified in the \u003ccode\u003e@endpoints.api\u003c/code\u003e decorator, are incorporated into the API's URL path, allowing for version management.\u003c/p\u003e\n"]]],[],null,[]]