Home  >  Article  >  Backend Development  >  proto nested structure cannot bind http

proto nested structure cannot bind http

WBOY
WBOYforward
2024-02-10 12:54:08952browse

proto nested structure cannot bind http

In PHP programming, the proto nested structure is a common data format used to serialize and deserialize data. However, many developers encounter a problem when using proto nested structures, which is that they cannot be bound into HTTP requests. This means that proto nested structures cannot be passed directly as parameters of HTTP requests. For this problem, PHP editor Xigua provides you with a solution. In this article, we will introduce a solution to help you bind proto nested structures to HTTP requests in PHP to achieve more convenient data transfer.

Problem content

When the kratos proto file uses the http interface, when the structure is nested, the parameter assignment cannot reach the structure

This is my prototype file

This is my request

This is my debugging

I want this:

pb.ListUserRequest{
   Page: {
      Index: 1,
      Size: 10,
   },
}

No binding parameters What should I do

Workaround

http cannot decode inner_object via "get"

  1. Use "post"
option (google.api.http) = {
      put: "/user/v1/list"
      body: "*"
    };

prototype:

message listuserrequest {
  page page = 1;
}

2. Do not use inner_object prototype:

message ListUserRequest {
  int32 index = 1;
  int32 size = 2;
}

The above is the detailed content of proto nested structure cannot bind http. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete