Skip to content

Commit

Permalink
http transport fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyashtrikul committed Nov 12, 2020
1 parent 85f9919 commit cebc018
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
5 changes: 2 additions & 3 deletions internal/transpoort/http/httpclient/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"go.opencensus.io/trace"

"github.com/vseinstrumentiru/lego/v2/internal/metrics/propagation"
httpTransport "github.com/vseinstrumentiru/lego/v2/transport/http"
)

type Constructor func(name string) *http.Client

func ConstructorProvider(httpProp *propagation.HTTPFormatCollection) Constructor {
func ConstructorProvider(httpProp *propagation.HTTPFormatCollection) httpTransport.Constructor {
return func(name string) *http.Client {
return &http.Client{
Transport: &ochttp.Transport{
Expand Down
3 changes: 1 addition & 2 deletions pkg/lehttp/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/shurcooL/graphql"

"github.com/vseinstrumentiru/lego/v2/internal/deprecated"
"github.com/vseinstrumentiru/lego/v2/internal/transpoort/http/httpclient"
httpTransport "github.com/vseinstrumentiru/lego/v2/transport/http"
)

Expand All @@ -18,7 +17,7 @@ type ClientOption = httpTransport.ClientOption
// Deprecated: use DI with httpclient.Constructor
func NewClient(name string, opts ...ClientOption) *baseHttp.Client {
var client *baseHttp.Client
err := deprecated.Container.Execute(func(c httpclient.Constructor) {
err := deprecated.Container.Execute(func(c httpTransport.Constructor) {
client = c(name)
})

Expand Down
2 changes: 2 additions & 0 deletions transport/http/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"go.opencensus.io/trace"
)

type Constructor func(name string) *http.Client

type ClientOption func(*http.Client)

func SetSpanNameFormatter(formatter func(req *http.Request) string) ClientOption {
Expand Down
29 changes: 29 additions & 0 deletions transport/http/resty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package http

import (
"fmt"

"github.com/go-resty/resty/v2"

"github.com/vseinstrumentiru/lego/v2/multilog"
)

func NewLogger(l multilog.Logger) resty.Logger {
return &logger{Logger: l}
}

type logger struct {
multilog.Logger
}

func (l *logger) Errorf(format string, v ...interface{}) {
l.Error(fmt.Sprintf(format, v...))
}

func (l *logger) Warnf(format string, v ...interface{}) {
l.Warn(fmt.Sprintf(format, v...))
}

func (l *logger) Debugf(format string, v ...interface{}) {
l.Debug(fmt.Sprintf(format, v...))
}

0 comments on commit cebc018

Please sign in to comment.