-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post requests do not support binding both body and query #2907
Comments
当前有解决方案吗? |
Is there a current solution? |
有没有其他解决方案,比较着急! |
Is there any other solution, more anxious! |
目前手动改模板是可以的,但是使用 make api 模板就会变更 比较麻烦 |
when to change the template |
service define rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
option (google.api.http) = {
post: "/users",
body: "user"
};
}
message CreateUserRequest {
string password = 1;
User user = 2;
}
message CreateUserResponse {
string response = 1;
}
message User {
string first_name = 1;
string last_name = 2;
}
in your service code func (s *GreeterService) CreateUser(ctx context.Context, req *v1.CreateUserRequest) (*v1.CreateUserResponse, error) {
info := fmt.Sprintf("password:%s,userName:%s %s", req.Password, req.User.FirstName, req.User.LastName)
return &v1.CreateUserResponse{Response: info}, nil
} test with curl curl --location -g --request POST 'http://127.0.0.1:8000/users?password=e77eEDab-BdAe-78BE-0979-2F798d9bBe4b \
--header 'Content-Type: application/json' \
--data-raw '{
"first_name":"czyt",
"last_name":"cn"
}' the curl response
|
What happened:
The Post request did not get the query parameter
What you expected to happen:
Get both body and query
How to reproduce it (as minimally and precisely as possible):
Post requests have both query and body
Anything else we need to know?:
Environment:
kratos -v
): v2.5.3go version
): go version go1.20.5 darwin/arm64cat /etc/os-release
): macosThe text was updated successfully, but these errors were encountered: