2024-11-16 23:57:58 +03:00
|
|
|
package httpconn
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.unistack.org/micro/v3/client"
|
|
|
|
"go.unistack.org/micro/v3/logger"
|
|
|
|
)
|
|
|
|
|
2024-11-17 18:54:44 +03:00
|
|
|
func Call(ctx context.Context, rquid string, l logger.Logger, c client.Client, addr string, td time.Duration, req client.Request, rsp interface{}, opts ...client.CallOption) error {
|
2024-11-16 23:57:58 +03:00
|
|
|
var err error
|
|
|
|
|
|
|
|
err = c.Call(ctx, req, rsp,
|
|
|
|
client.WithAddress(addr),
|
|
|
|
client.WithRequestTimeout(td),
|
|
|
|
// client.WithContentType("application/json"),
|
|
|
|
)
|
|
|
|
if err != nil {
|
2024-11-17 18:54:44 +03:00
|
|
|
// httpcli.GetError(err)
|
|
|
|
l.Error(ctx, "call failed", "x-request-id", rquid, err)
|
2024-11-16 23:57:58 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|