Skip to content

[Question] The update_mask field in PATCH method request does not work #3742

@RyoJerryYu

Description

@RyoJerryYu

In gRPC-Gateway , there is a patch feature, aimed to allow a resource to be partially updated.

Patch feature | gRPC-Gateway

If a binding is mapped to patch and the request message has exactly one FieldMask message in it, additional code is rendered for the gateway handler that will populate the FieldMask based on the request body.

It means if I have a method like this:

service AppSvc {
  rpc UpdateApp(UpdateAppReq) returns (UpdateAppResp) {
    option (google.api.http) = {
      patch: "/api/v1/apps/{app.id}"
      body: "app"
    };
    option (google.api.method_signature) = "app,update_mask";
  }
}

message UpdateAppReq {
  App app = 1;
  google.protobuf.FieldMask update_mask = 2; // 由 gRPC-Gateway 框架填入
}
message UpdateAppResp {
  App app = 1;
}

And do a PATCH request:

curl -X 'PATCH' \
  'http://localhost:8000/api/v1/apps/8' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "beam"
}'

Then I can get the update_mask value from the server side, and use the update_mask value to do partial update in SQL.

But when I do the same with Kratos HTTP Server, I can only get the UpdateMask field to be nil .

So, my question: Do Kratos support this patch feature as gRPC-Gateway?
If so, how can I use it?
If not, does Kratos plan to support it in the future?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions