diff --git a/repository/user_authentication.go b/repository/user_authentication.go index b70638c..12aa56d 100644 --- a/repository/user_authentication.go +++ b/repository/user_authentication.go @@ -7,14 +7,11 @@ import ( "github.com/pkg/errors" "github.com/txix-open/isp-kit/http/httpcli" + "github.com/txix-open/isp-kit/http/httpclix" "github.com/txix-open/isp-kit/lb" "github.com/txix-open/isp-kit/metrics/http_metrics" ) -const ( - userAuthenticateFmt = "http://%s/%s/authenticate" -) - type UserAuth struct { lb *lb.RoundRobin cli *httpcli.Client @@ -23,7 +20,7 @@ type UserAuth struct { func NewUserAuth(lb *lb.RoundRobin) UserAuth { return UserAuth{ lb: lb, - cli: httpcli.New(), + cli: httpclix.Default(), } } @@ -32,15 +29,16 @@ func (r UserAuth) Authenticate( authModuleName string, token string, ) (*entity.UserAuthenticateResponse, error) { - ctx = http_metrics.ClientEndpointToContext(ctx, userAuthenticateFmt) + method := fmt.Sprintf("%s/authenticate", authModuleName) + + ctx = http_metrics.ClientEndpointToContext(ctx, method) host, err := r.lb.Next() if err != nil { return nil, errors.WithMessage(err, "lb next") } - endpoint := fmt.Sprintf(userAuthenticateFmt, host, authModuleName) - + endpoint := fmt.Sprintf("http://%s/%s", host, method) resp := entity.UserAuthenticateResponse{} err = r.cli.Post(endpoint). JsonRequestBody(entity.UserAuthenticateRequest{