go-kratos / kratos-layout

Kratos Project Template
http://go-kratos.dev
MIT License
411 stars 212 forks source link

Client.Invoke CallOption 无效 #81

Closed windzhu0514 closed 2 years ago

windzhu0514 commented 2 years ago
client := v1.NewGreeterHTTPClient(httpClient)
client.SayHello(context.Background(), &v1.HelloRequest{}, http.Operation("/helloxxx")) // 指定Operation

func (c *GreeterHTTPClientImpl) SayHello(ctx context.Context, in *HelloRequest, opts ...http.CallOption) (*HelloReply, error) {
    var out HelloReply
    pattern := "/helloworld/{name}"
    path := binding.EncodeURL(pattern, in, true)
        // 指定的Operation在前,被以下语句添加的Operation覆盖
    opts = append(opts, http.Operation("/helloworld.v1.Greeter/SayHello"))
    opts = append(opts, http.PathTemplate(pattern))
    err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
    if err != nil {
        return nil, err
    }
    return &out, err
}
shenqidebaozi commented 2 years ago

实际请求的路径是path,operation是 http grpc同构使用的,不过不能覆盖的确是个bug, issue应该提交到kratos仓库中