HTTP and gRPC mapping question for grpc_gateway

28 views
Skip to first unread message

Brad Post

unread,
Oct 17, 2024, 12:10:41 PM10/17/24
to grpc.io

Hello,

Trying to get some clarification on the HTTP to gRPC mapping as I would
like to do the following mapping when sending in resource ids:

- HTTP: PATCH /v1/keys/1234
- gRPC: patch_key(Data: UpdateKeyRequestData(UpdateKeyId: `1234`))


But seems that due to the HTTP body rules and how gRPC is mapped I can only
have the resource ID at the top level message, not replaced in a sub-message.

Am I correctly understanding this or is there a way to get the resource ID
into a sub-message.

My code is below for reference and thanks in advance for any help.

Brad

------

// Defines the UpdateKeyRequestData message
message UpdateKeyRequestData {
// The key id
string UpdateKeyId = 1;
}

message PatchKeyRequest {
// The data needed to create a Key
UpdateKeyRequestData Data = 1;
}

//
// Patch a key
rpc patch_key(PatchKeyRequest) returns (KeyResponse) {
option (google.api.http) = {
patch: "/v1/keys/{PatchKeyId}"
body: "*"
};
}

Reply all
Reply to author
Forward
0 new messages