@@ -21,12 +21,15 @@ import (
2121 "errors"
2222 "fmt"
2323 "github.com/cisco-open/go-lanai/pkg/discovery"
24+ "github.com/cisco-open/go-lanai/pkg/utils"
2425 "github.com/cisco-open/go-lanai/pkg/utils/order"
26+ "net/url"
2527 "time"
2628)
2729
2830var (
2931 insecureInstanceMatcher = discovery .InstanceWithTagKV ("secure" , "false" , true )
32+ supportedSchemes = utils .NewStringSet ("http" , "https" )
3033)
3134
3235type clientDefaults struct {
@@ -105,17 +108,6 @@ func (c *client) WithBaseUrl(baseUrl string) (Client, error) {
105108 return cp .WithConfig (defaultExtHostConfig ()), nil
106109}
107110
108- func (c * client ) WithNoTargetResolver () (Client , error ) {
109- endpointer , e := NewNoOpTargetResolver ()
110- if e != nil {
111- return nil , NewNoEndpointFoundError (fmt .Errorf ("cannot create client" ), e )
112- }
113-
114- cp := c .shallowCopy ()
115- cp .resolver = endpointer
116- return cp .WithConfig (defaultExtHostConfig ()), nil
117- }
118-
119111func (c * client ) WithConfig (config * ClientConfig ) Client {
120112 mergeConfig (config , c .config )
121113 cp := c .shallowCopy ()
@@ -214,9 +206,13 @@ func (c *client) shallowCopy() *client {
214206
215207func (c * client ) executor (request * Request , resolver TargetResolver , dec DecodeResponseFunc ) Retryable {
216208 return func (ctx context.Context ) (interface {}, error ) {
217- target , e := resolver .Resolve (ctx , request )
218- if e != nil {
219- return nil , e
209+ target , e := url .Parse (request .Path )
210+ // only need to resolve the target if the request.Path is not absolute
211+ if e != nil || ! supportedSchemes .Has (target .Scheme ) {
212+ target , e = resolver .Resolve (ctx , request )
213+ if e != nil {
214+ return nil , e
215+ }
220216 }
221217
222218 req , e := request .CreateFunc (ctx , request .Method , target )
0 commit comments