You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/01/04 08:19:00 UTC

[jira] [Commented] (SCB-161) Optimize restful client

    [ https://issues.apache.org/jira/browse/SCB-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16310963#comment-16310963 ] 

ASF GitHub Bot commented on SCB-161:
------------------------------------

little-cui closed pull request #240: SCB-161 Optimize restful client.
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/240
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pkg/rest/client.go b/pkg/rest/client.go
index 361c1c8d..3ce4e29c 100644
--- a/pkg/rest/client.go
+++ b/pkg/rest/client.go
@@ -30,6 +30,7 @@ import (
 	"net/http"
 	"reflect"
 	"time"
+	"net/url"
 )
 
 const (
@@ -117,7 +118,7 @@ func GetHttpsClient(gzip, verifyPeer bool) (client *HttpClient, err error) {
 	return getHttpsClient(gzip, verifyPeer, true, false)
 }
 
-func GetClient(scheme string) (*HttpClient, error) {
+func getClientByScheme(scheme string) (*HttpClient, error) {
 	var err error
 	var client *HttpClient
 	if scheme == "https" {
@@ -136,6 +137,16 @@ func GetClient(scheme string) (*HttpClient, error) {
 	return client, nil
 }
 
+func GetClient(urlPath string) (*HttpClient, error) {
+	var err error
+	urlParsed, err := url.Parse(urlPath)
+	if err != nil {
+		util.Logger().Errorf(err, "nonstandard url %s", urlPath)
+		return nil, err
+	}
+	return getClientByScheme(urlParsed.Scheme)
+}
+
 /**
   获取TLS认证HTTP客户端
   gzip  控制是否支持压缩


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Optimize restful client
> -----------------------
>
>                 Key: SCB-161
>                 URL: https://issues.apache.org/jira/browse/SCB-161
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Service-Center
>            Reporter: little-cui
>             Fix For: service-center-1.0.0-m1
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)