Skip to content

Commit

Permalink
Merge pull request #408 from Patrick0308/rest
Browse files Browse the repository at this point in the history
Fix problem of rest protocol PR #352
  • Loading branch information
zouyx authored Mar 15, 2020
2 parents dafc2f4 + 72fac64 commit 8c53128
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
17 changes: 17 additions & 0 deletions common/yaml/yaml_test.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 (
Expand Down
8 changes: 2 additions & 6 deletions protocol/rest/client/client_impl/resty_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion protocol/rest/rest_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 8c53128

Please sign in to comment.