作者:霓Nin氵ini | 来源:互联网 | 2022-11-23 15:44
让我们从官方文档中拿这个例子:
// Updates a book.
rpc UpdateBook(UpdateBookRequest) returns (Book) {
// Update maps to HTTP PATCH. Resource name is mapped to a URL path.
// Resource is contained in the HTTP request body.
option (google.api.http) = {
// Note the URL template variable which captures the resource name of the
// book to update.
patch: "/v1/{book.name=shelves/*/books/*}"
body: "book"
};
}
message UpdateBookRequest {
// The book resource which replaces the resource on the server.
Book book = 1;
// The update mask applies to the resource. For the `FieldMask` definition,
// see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
FieldMask update_mask = 2;
}
如果我没有grpc网关并且只使用grpc,我可以这样使用mask:
// Updates a book.
rpc UpdateBook(UpdateBookRequest) returns (Book);
message UpdateBookRequest {
// The book resource which replaces the resource on the server.
Book book = 1;
// The update mask applies to the resource. For the `FieldMask` definition,
// see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
FieldMask update_mask = 2;
}
如果是这样,该掩码应如何工作 - 过滤请求?或者在db保存期间应用它以及它如何知道db ...所以我对使用它有点困惑.在我自己的grpc示例中,我看到该掩码不会过滤请求.