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

proto nested structure cannot bind http

WBOY
Release: 2024-02-10 12:54:08
forward
993 people have browsed it

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,
   },
}
Copy after login

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: "*"
    };
Copy after login

prototype:

message listuserrequest {
  page page = 1;
}
Copy after login

2. Do not use inner_object prototype:

message ListUserRequest {
  int32 index = 1;
  int32 size = 2;
}
Copy after login

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template