diff --git a/common/yaml/yaml_test.go b/common/yaml/yaml_test.go index 8d0eefddc2..994e1595c4 100644 --- a/common/yaml/yaml_test.go +++ b/common/yaml/yaml_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package yaml import ( diff --git a/config/rest/config_reader/reader_impl/default_config_reader.go b/config/rest/config_reader/reader_impl/default_config_reader.go index 40e1ecf9a0..89cf247483 100644 --- a/config/rest/config_reader/reader_impl/default_config_reader.go +++ b/config/rest/config_reader/reader_impl/default_config_reader.go @@ -18,8 +18,6 @@ package reader_impl import ( - "github.com/apache/dubbo-go/config/rest" - "github.com/apache/dubbo-go/config/rest/config_reader" "os" ) @@ -31,6 +29,8 @@ import ( "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/yaml" + "github.com/apache/dubbo-go/config/rest" + "github.com/apache/dubbo-go/config/rest/config_reader" ) var ( diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index 839936695d..aa6c23137d 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -37,14 +37,14 @@ import ( ) func init() { - extension.SetRestClient(constant.DEFAULT_REST_CLIENT, GetRestyClient) + extension.SetRestClient(constant.DEFAULT_REST_CLIENT, NewRestyClient) } type RestyClient struct { client *resty.Client } -func NewRestyClient(restOption *client.RestOptions) *RestyClient { +func NewRestyClient(restOption *client.RestOptions) client.RestClient { client := resty.New() client.SetTransport( &http.Transport{ @@ -83,7 +83,3 @@ func (rc *RestyClient) Do(restRequest *client.RestRequest, res interface{}) erro } return nil } - -func GetRestyClient(restOptions *client.RestOptions) client.RestClient { - return NewRestyClient(restOptions) -} diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index b6eaa17334..75dd762c68 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -148,7 +148,7 @@ func TestRestInvoker_Invoke(t *testing.T) { configMap["com.ikurento.user.UserProvider"] = &rest.RestServiceConfig{ RestMethodConfigsMap: methodConfigMap, } - restClient := client_impl.GetRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second, RequestTimeout: 3 * time.Second}) + restClient := client_impl.NewRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second, RequestTimeout: 3 * time.Second}) invoker := NewRestInvoker(url, &restClient, methodConfigMap) user := &User{} inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"),