// The greeting service definition.serviceGreeter{// Sends a greetingrpcSayHello(HelloRequest)returns(HelloReply){}}// The request message containing the user's name.messageHelloRequest{stringname=1;}// The response message containing the greetingsmessageHelloReply{stringmessage=1;}
如要搭配 API Gateway 使用 gRPC,您必須提供服務設定以及服務定義。這會設定服務的執行階段行為,包含驗證、服務中的 API、從 HTTP 要求到 gRPC 方法的對應,以及特殊的 API Gateway 設定。
轉碼
API Gateway 會為 Cloud Run 上的 gRPC 服務提供通訊協定轉譯,讓用戶端可使用 HTTP/JSON 透過 API Gateway 與 gRPC 服務進行通訊。
[[["容易理解","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-06-16 (世界標準時間)。"],[[["gRPC is a high-performance, open-source RPC framework that allows client applications to directly call methods on a server application as if they were local objects."],["API Gateway for gRPC enhances gRPC services by offering API management features such as monitoring, hosting, tracing, and authentication."],["API Gateway can translate RESTful JSON over HTTP into gRPC requests, enabling flexibility by supporting both gRPC and JSON/HTTP clients."],["gRPC services use protocol buffers as the Interface Definition Language (IDL) to define services, methods, parameters, and return types, and require a service configuration for runtime behavior."],["API Gateway supports protocol translation for gRPC services, enabling HTTP/JSON clients to interact with gRPC services, but payload compression and IDLs other than protocol buffers are not currently supported."]]],[]]