This is an automated email from the ASF dual-hosted git repository.

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-mesher.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a65d1d  adapt go chassis 2.1.0 (#140)
7a65d1d is described below

commit 7a65d1dbc577d385b76abda37296bef9c8c1ab5d
Author: Shawn <[email protected]>
AuthorDate: Thu Feb 25 19:52:15 2021 +0800

    adapt go chassis 2.1.0 (#140)
---
 .github/workflows/golangci-lint.yml                | 12 +---
 proxy/cmd/cmd.go                                   |  2 +-
 proxy/handler/port_rewrite.go                      |  5 +-
 proxy/handler/skywalking_handler.go                |  7 +-
 proxy/handler/skywalking_handler_test.go           |  2 +-
 proxy/pkg/egress/egress.go                         |  8 +--
 proxy/pkg/egress/egress_test.go                    | 13 ++--
 proxy/pkg/infras/k8s/k8s.go                        | 77 ----------------------
 proxy/pkg/infras/k8s/k8s_test.go                   | 59 -----------------
 proxy/pkg/metrics/metrics.go                       |  2 -
 proxy/pkg/metrics/prom_recorder.go                 |  3 -
 proxy/pkg/metrics/prometheus_exporter.go           |  1 -
 proxy/pkg/skywalking/skywalking_manager.go         |  6 +-
 proxy/pkg/skywalking/skywalking_manager_test.go    |  2 +-
 proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go    |  6 +-
 .../protocol/dubbo/proxy/dubbo_proxy_ouput_test.go |  2 +-
 proxy/protocol/grpc/client.go                      |  7 --
 proxy/protocol/grpc/reverse_proxy.go               |  2 +-
 proxy/protocol/grpc/struct.go                      | 75 ---------------------
 proxy/protocol/http/sidecar.go                     | 27 ++++----
 scripts/travis/unit_test.sh                        | 13 +---
 21 files changed, 41 insertions(+), 290 deletions(-)

diff --git a/.github/workflows/golangci-lint.yml 
b/.github/workflows/golangci-lint.yml
index 9640ae5..f446a05 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -1,11 +1,5 @@
 name: golangci-lint
-on:
-  push:
-    tags:
-      - v*
-    branches:
-      - master
-  pull_request:
+on: [push, pull_request]
 jobs:
   golangci:
     name: lint
@@ -15,5 +9,5 @@ jobs:
       - name: golangci-lint
         uses: golangci/golangci-lint-action@v2
         with:
-          version: v1.29
-          args: --skip-dirs=examples --out-format=colored-line-number 
--skip-files=.*_test.go$
\ No newline at end of file
+          version: v1.37.1
+          args: --skip-dirs=examples,proxy/protocol/dubbo 
--out-format=colored-line-number --skip-files=.*_test.go$
\ No newline at end of file
diff --git a/proxy/cmd/cmd.go b/proxy/cmd/cmd.go
index 2e66e22..786dc59 100644
--- a/proxy/cmd/cmd.go
+++ b/proxy/cmd/cmd.go
@@ -62,7 +62,7 @@ func parseConfigFromCmd(args []string) (err error) {
                cli.StringFlag{
                        Name:        "service-ports",
                        EnvVar:      common.EnvServicePorts,
-                       Usage:       fmt.Sprintf("service protocol and 
port,examples: --service-ports=http:3000,grpc:8000"),
+                       Usage:       "service protocol and port,examples: 
--service-ports=http:3000,grpc:8000",
                        Destination: &Configs.LocalServicePorts,
                },
        }
diff --git a/proxy/handler/port_rewrite.go b/proxy/handler/port_rewrite.go
index c19172f..68d5103 100644
--- a/proxy/handler/port_rewrite.go
+++ b/proxy/handler/port_rewrite.go
@@ -78,5 +78,8 @@ func New() handler.Handler {
 }
 
 func init() {
-       handler.RegisterHandler(PortMapForPilot, New)
+       err := handler.RegisterHandler(PortMapForPilot, New)
+       if err != nil {
+               openlog.Error(err.Error())
+       }
 }
diff --git a/proxy/handler/skywalking_handler.go 
b/proxy/handler/skywalking_handler.go
index db67b3f..72f09f4 100644
--- a/proxy/handler/skywalking_handler.go
+++ b/proxy/handler/skywalking_handler.go
@@ -52,12 +52,11 @@ func (sp *SkyWalkingProviderHandler) Handle(chain 
*handler.Chain, i *invocation.
        chain.Next(i, func(r *invocation.Response) {
                cb(r)
                span.Tag(go2sky.TagHTTPMethod, i.Protocol)
-               span.Tag(go2sky.TagURL, 
HTTPPrefix+i.MicroServiceName+i.URLPathFormat)
+               span.Tag(go2sky.TagURL, HTTPPrefix+i.MicroServiceName+i.URLPath)
                span.Tag(go2sky.TagStatusCode, strconv.Itoa(r.Status))
                span.SetSpanLayer(skycom.SpanLayer_Http)
                span.SetComponent(HTTPServerComponentID)
                span.End()
-               return
        })
 }
 
@@ -89,13 +88,13 @@ func (sc *SkyWalkingConsumerHandler) Handle(chain 
*handler.Chain, i *invocation.
        chain.Next(i, func(r *invocation.Response) {
                cb(r)
                span.Tag(go2sky.TagHTTPMethod, i.Protocol)
-               span.Tag(go2sky.TagURL, 
HTTPPrefix+i.MicroServiceName+i.URLPathFormat)
+               span.Tag(go2sky.TagURL, HTTPPrefix+i.MicroServiceName+i.URLPath)
                span.Tag(go2sky.TagStatusCode, strconv.Itoa(r.Status))
                span.SetSpanLayer(skycom.SpanLayer_Http)
                span.SetComponent(HTTPServerComponentID)
 
                spanExit.Tag(go2sky.TagHTTPMethod, i.Protocol)
-               spanExit.Tag(go2sky.TagURL, 
HTTPPrefix+i.MicroServiceName+i.URLPathFormat)
+               spanExit.Tag(go2sky.TagURL, 
HTTPPrefix+i.MicroServiceName+i.URLPath)
                spanExit.Tag(go2sky.TagStatusCode, strconv.Itoa(r.Status))
                spanExit.SetSpanLayer(skycom.SpanLayer_Http)
                spanExit.SetComponent(HTTPClientComponentID)
diff --git a/proxy/handler/skywalking_handler_test.go 
b/proxy/handler/skywalking_handler_test.go
index 350d8cd..c08ea1d 100644
--- a/proxy/handler/skywalking_handler_test.go
+++ b/proxy/handler/skywalking_handler_test.go
@@ -53,7 +53,7 @@ func initInv() *invocation.Invocation {
        i.MicroServiceName = "test"
        i.Ctx = context.Background()
        i.Endpoint = "calculator"
-       i.URLPathFormat = "/bmi"
+       i.URLPath = "/bmi"
        return &i
 }
 
diff --git a/proxy/pkg/egress/egress.go b/proxy/pkg/egress/egress.go
index ae712a6..523bf0f 100644
--- a/proxy/pkg/egress/egress.go
+++ b/proxy/pkg/egress/egress.go
@@ -23,14 +23,8 @@ import (
        meshercontrol "github.com/apache/servicecomb-mesher/proxy/control"
        "github.com/go-chassis/go-chassis/v2/control"
        "regexp"
-       "sync"
 )
 
-var lock sync.RWMutex
-
-var plainHosts = make(map[string]*config.EgressRule)
-var regexHosts = make(map[string]*config.EgressRule)
-
 //Egress return egress rule, you can also set custom egress rule
 type Egress interface {
        Init(Options) error
@@ -102,7 +96,7 @@ func Match(hostname string) (bool, *control.EgressConfig) {
                        } else if string(host[0]) == "*" {
                                substring := host[1:]
                                match, _ := regexp.MatchString(substring+"$", 
hostname)
-                               if match == true {
+                               if match {
                                        return true, &egress
                                }
                        }
diff --git a/proxy/pkg/egress/egress_test.go b/proxy/pkg/egress/egress_test.go
index 5703ce2..1ac9fab 100644
--- a/proxy/pkg/egress/egress_test.go
+++ b/proxy/pkg/egress/egress_test.go
@@ -28,7 +28,6 @@ import (
 
        "github.com/apache/servicecomb-mesher/proxy/cmd"
        mesherconfig "github.com/apache/servicecomb-mesher/proxy/config"
-       _ "github.com/apache/servicecomb-mesher/proxy/control/istio"
        "github.com/apache/servicecomb-mesher/proxy/pkg/egress"
        "github.com/apache/servicecomb-mesher/proxy/pkg/egress/archaius"
        "github.com/go-chassis/go-chassis/v2/control"
@@ -44,7 +43,6 @@ func init() {
 func BenchmarkMatch(b *testing.B) {
        chassis := []byte(`
 cse:
-  service:
     registry:
       #disabled: false           optional:禁用注册发现选项,默认开始注册发现
       type: servicecenter           
#optional:可选zookeeper/servicecenter,zookeeper供中软使用,不配置的情况下默认为servicecenter
@@ -101,8 +99,7 @@ egressRule:
 func TestMatch(t *testing.T) {
 
        b := []byte(`
-cse:
-  service:
+servicecomb:
     registry:
       #disabled: false           optional:禁用注册发现选项,默认开始注册发现
       type: servicecenter           
#optional:可选zookeeper/servicecenter,zookeeper供中软使用,不配置的情况下默认为servicecenter
@@ -118,11 +115,9 @@ cse:
        _, err = f1.Write(b)
        b = []byte(`
 ---
-#微服务的私有属性
-#APPLICATION_ID: CSE #optional
-service_description:
-  name: Client
-  #version: 0.1 #optional
+servicecomb
+  service:
+    name: Client
 
 `)
        d, _ = os.Getwd()
diff --git a/proxy/pkg/infras/k8s/k8s.go b/proxy/pkg/infras/k8s/k8s.go
deleted file mode 100644
index 7d93b07..0000000
--- a/proxy/pkg/infras/k8s/k8s.go
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 pilotv2
-
-import (
-       "k8s.io/apimachinery/pkg/runtime"
-       "k8s.io/apimachinery/pkg/runtime/schema"
-       "k8s.io/apimachinery/pkg/runtime/serializer"
-       "k8s.io/client-go/rest"
-       "k8s.io/client-go/tools/clientcmd"
-)
-
-//DestinationRuleResult is the list of MinDestinationRules
-type DestinationRuleResult struct {
-       Items []MinDestinationRule
-}
-
-// MinDestinationRule is the minimum structure we need to get subsets
-type MinDestinationRule struct {
-       Metadata struct {
-               Name      string `json:"name"`
-               Namespace string `json:"namespace"`
-       } `json:"metadata"`
-       Spec struct {
-               Host    string `json:"host"`
-               Subsets []struct {
-                       Labels map[string]string `json:"labels"`
-                       Name   string            `json:"name"`
-               } `json:"subsets"`
-       } `json:"spec"`
-}
-
-//CreateK8SRestClient returns the kubernetes client for RESTful API calls
-func CreateK8SRestClient(kubeconfig, apiPath, group, version string) 
(*rest.RESTClient, error) {
-       var config *rest.Config
-       var err error
-       if kubeconfig != "" {
-               config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
-               if err != nil {
-                       config, err = rest.InClusterConfig()
-               }
-       } else {
-               config, err = rest.InClusterConfig()
-       }
-
-       if err != nil {
-               return nil, err
-       }
-
-       config.APIPath = apiPath
-       config.GroupVersion = &schema.GroupVersion{
-               Group:   group,
-               Version: version,
-       }
-       config.NegotiatedSerializer = 
serializer.NewCodecFactory(runtime.NewScheme())
-
-       k8sRestClient, err := rest.RESTClientFor(config)
-       if err != nil {
-               return nil, err
-       }
-       return k8sRestClient, nil
-}
diff --git a/proxy/pkg/infras/k8s/k8s_test.go b/proxy/pkg/infras/k8s/k8s_test.go
deleted file mode 100644
index 5651e30..0000000
--- a/proxy/pkg/infras/k8s/k8s_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 pilotv2
-
-import (
-       "os"
-       "os/user"
-       "testing"
-)
-
-var KubeConfig string
-
-func init() {
-       if KUBE_CONFIG := os.Getenv("KUBE_CONFIG"); KUBE_CONFIG != "" {
-               KubeConfig = KUBE_CONFIG
-       } else {
-               usr, err := user.Current()
-               if err != nil {
-                       panic("Failed to get current user info: " + err.Error())
-               } else {
-                       KubeConfig = usr.HomeDir + "/" + ".kube/config"
-               }
-       }
-
-}
-
-func TestCreateK8sClient(t *testing.T) {
-       _, err := CreateK8SRestClient(KubeConfig, "apis", 
"networking.istio.io", "v1alpha3")
-       if err != nil {
-               t.Errorf("Failed to create k8s rest client: %s", err.Error())
-       }
-
-       _, err = CreateK8SRestClient("*nonfile", "apis", "networking.istio.io", 
"v1alpha3")
-       if err == nil {
-               t.Errorf("Test failed, should return error with invalid kube 
config path")
-       }
-}
-
-func TestCreateInvalidK8sClient(t *testing.T) {
-       _, err := CreateK8SRestClient("", "apis", "networking.istio.io", 
"v1alpha3")
-       if err == nil {
-               t.Errorf("Passing a nil config for k8s client should return 
error")
-       }
-}
diff --git a/proxy/pkg/metrics/metrics.go b/proxy/pkg/metrics/metrics.go
index 07d11aa..522cc9c 100644
--- a/proxy/pkg/metrics/metrics.go
+++ b/proxy/pkg/metrics/metrics.go
@@ -24,7 +24,6 @@ package metrics
 
 import (
        "github.com/go-chassis/go-chassis/v2/pkg/runtime"
-       "sync"
        "time"
 )
 
@@ -46,7 +45,6 @@ const (
 var (
        //LabelNames is a fixed list with service name, appID, version
        LabelNames = []string{LServiceName, LApp, LVersion}
-       mutex      = sync.Mutex{}
 )
 
 //Options define recorder options
diff --git a/proxy/pkg/metrics/prom_recorder.go 
b/proxy/pkg/metrics/prom_recorder.go
index dfa5164..deeaf61 100644
--- a/proxy/pkg/metrics/prom_recorder.go
+++ b/proxy/pkg/metrics/prom_recorder.go
@@ -20,12 +20,9 @@ package metrics
 import (
        "errors"
        "net/http"
-       "sync"
        "time"
 )
 
-var onceEnable sync.Once
-
 //PromRecorder record metrics
 type PromRecorder struct {
        LabelNames []string
diff --git a/proxy/pkg/metrics/prometheus_exporter.go 
b/proxy/pkg/metrics/prometheus_exporter.go
index f0cfe2e..c0aae6b 100644
--- a/proxy/pkg/metrics/prometheus_exporter.go
+++ b/proxy/pkg/metrics/prometheus_exporter.go
@@ -45,7 +45,6 @@ type PrometheusMesherSinker struct {
 var (
        //DefaultPrometheusExporter stores value of default prometheus exporter 
type
        DefaultPrometheusExporter = GetPrometheusExporter()
-       onceInit                  sync.Once
        //DefaultPrometheusSinker stores value of default prometheus exporter 
type
        DefaultPrometheusSinker *PrometheusMesherSinker
 )
diff --git a/proxy/pkg/skywalking/skywalking_manager.go 
b/proxy/pkg/skywalking/skywalking_manager.go
index ed0b742..a841546 100644
--- a/proxy/pkg/skywalking/skywalking_manager.go
+++ b/proxy/pkg/skywalking/skywalking_manager.go
@@ -41,14 +41,14 @@ var tracer *go2sky.Tracer
 
 //CreateEntrySpan use tracer to create and start an entry span for incoming 
request
 func CreateEntrySpan(i *invocation.Invocation) (go2sky.Span, context.Context, 
error) {
-       return tracer.CreateEntrySpan(i.Ctx, 
i.MicroServiceName+i.URLPathFormat, func() (string, error) {
+       return tracer.CreateEntrySpan(i.Ctx, i.MicroServiceName+i.URLPath, 
func() (string, error) {
                return i.Headers()[CrossProcessProtocolV2], nil
        })
 }
 
 //CreateExitSpan use tracer to create and start an exit span for client
 func CreateExitSpan(ctx context.Context, i *invocation.Invocation) 
(go2sky.Span, error) {
-       return tracer.CreateExitSpan(ctx, i.MicroServiceName+i.URLPathFormat, 
i.Endpoint+i.URLPathFormat, func(header string) error {
+       return tracer.CreateExitSpan(ctx, i.MicroServiceName+i.URLPath, 
i.Endpoint+i.URLPath, func(header string) error {
                i.SetHeader(CrossProcessProtocolV2, header)
                return nil
        })
@@ -76,5 +76,5 @@ func Init() {
                openlog.Error(fmt.Sprintf("NewTracer error " + err.Error()))
        }
        //tracer.WaitUntilRegister()
-       openlog.Debug(fmt.Sprintf("SkyWalking manager Init end"))
+       openlog.Debug("SkyWalking manager Init end")
 }
diff --git a/proxy/pkg/skywalking/skywalking_manager_test.go 
b/proxy/pkg/skywalking/skywalking_manager_test.go
index 4d04d6a..53af65b 100644
--- a/proxy/pkg/skywalking/skywalking_manager_test.go
+++ b/proxy/pkg/skywalking/skywalking_manager_test.go
@@ -51,7 +51,7 @@ func initInv() *invocation.Invocation {
        i.MicroServiceName = "test"
        i.Ctx = context.Background()
        i.Endpoint = "calculator"
-       i.URLPathFormat = "/bmi"
+       i.URLPath = "/bmi"
        return &i
 }
 
diff --git a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go 
b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
index b7ffc03..4ed4bac 100755
--- a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
+++ b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput.go
@@ -69,8 +69,8 @@ func (e ProxyError) Error() string {
 func SetLocalServiceAddress(inv *invocation.Invocation) error {
        inv.Endpoint = cmd.Configs.PortsMap[inv.Protocol]
        if inv.Endpoint == "" {
-               if inv.Port != "" {
-                       inv.Endpoint = "127.0.0.1:" + inv.Port
+               if inv.PortName != "" {
+                       inv.Endpoint = "127.0.0.1:" + inv.PortName
                        cmd.Configs.PortsMap[inv.Protocol] = inv.Endpoint
                        return nil
                } else {
@@ -97,7 +97,7 @@ func Handle(ctx *dubbo.InvokeContext) error {
        inv.MicroServiceName = svc.ServiceName
        inv.RouteTags = utiltags.NewDefaultTag(svc.Version, svc.AppID)
        inv.Protocol = "dubbo"
-       inv.URLPathFormat = ""
+       inv.URLPath = ""
        inv.Reply = &dubboclient.WrapResponse{nil} //&rest.Response{Resp: 
&ctx.Response}
        var err error
        err = SetLocalServiceAddress(inv) //select local service
diff --git a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput_test.go 
b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput_test.go
index 24750ea..62c1d95 100644
--- a/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput_test.go
+++ b/proxy/protocol/dubbo/proxy/dubbo_proxy_ouput_test.go
@@ -60,7 +60,7 @@ func TestSetLocalServiceAddress(t *testing.T) {
                assert.Error(t, err)
 
                // case port
-               inv.Port = "8080"
+               inv.PortName = "8080"
                err = SetLocalServiceAddress(inv)
                assert.NoError(t, err)
        })
diff --git a/proxy/protocol/grpc/client.go b/proxy/protocol/grpc/client.go
index 0291fcf..641eb4d 100644
--- a/proxy/protocol/grpc/client.go
+++ b/proxy/protocol/grpc/client.go
@@ -25,7 +25,6 @@ import (
        "net/http"
 
        "github.com/go-chassis/go-chassis/v2/core/client"
-       "github.com/go-chassis/go-chassis/v2/core/common"
        "github.com/go-chassis/go-chassis/v2/core/invocation"
        "github.com/go-chassis/go-chassis/v2/pkg/util/httputil"
        "golang.org/x/net/http2"
@@ -77,12 +76,6 @@ func NewClient(opts client.Options) (client.ProtocolClient, 
error) {
        }, nil
 }
 
-func (c *Client) contextToHeader(ctx context.Context, req *http.Request) {
-       for k, v := range common.FromContext(ctx) {
-               req.Header.Set(k, v)
-       }
-}
-
 //Call is a method which uses grpc protocol to transfer invocation
 func (c *Client) Call(ctx context.Context, addr string, inv 
*invocation.Invocation, rsp interface{}) error {
        var err error
diff --git a/proxy/protocol/grpc/reverse_proxy.go 
b/proxy/protocol/grpc/reverse_proxy.go
index e0b8e91..f35db78 100755
--- a/proxy/protocol/grpc/reverse_proxy.go
+++ b/proxy/protocol/grpc/reverse_proxy.go
@@ -65,7 +65,7 @@ func preHandler(req *http.Request) *invocation.Invocation {
        inv.Args = req
        inv.Protocol = "grpc"
        inv.Reply = rest.NewResponse()
-       inv.URLPathFormat = req.URL.Path
+       inv.URLPath = req.URL.Path
        return inv
 }
 
diff --git a/proxy/protocol/grpc/struct.go b/proxy/protocol/grpc/struct.go
deleted file mode 100644
index 75b218e..0000000
--- a/proxy/protocol/grpc/struct.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 grpc
-
-import (
-       "github.com/gogo/protobuf/proto"
-       "google.golang.org/grpc/encoding"
-)
-
-type frame struct {
-       payload []byte
-}
-
-type codec struct {
-       protoCodec encoding.Codec
-}
-
-//Marshal encode struct into bytes
-func (c *codec) Marshal(f interface{}) ([]byte, error) {
-       b, ok := f.(*frame)
-       if !ok {
-               return c.protoCodec.Marshal(f)
-       }
-       return b.payload, nil
-
-}
-
-//Unmarshal decode bytes into struct
-func (c *codec) Unmarshal(d []byte, f interface{}) error {
-       b, ok := f.(*frame)
-       if !ok {
-               return c.protoCodec.Unmarshal(d, f)
-       }
-       b.payload = d
-       return nil
-}
-
-//String return name
-func (c *codec) String() string {
-       return "proxy_codec"
-}
-
-type protobufCodec struct {
-}
-
-//Marshal encode struct into bytes
-func (c *protobufCodec) Marshal(f interface{}) ([]byte, error) {
-       return proto.Marshal(f.(proto.Message))
-
-}
-
-//Unmarshal decode bytes into struct
-func (c *protobufCodec) Unmarshal(d []byte, f interface{}) error {
-       return proto.UnmarshalMerge(d, f.(proto.Message))
-}
-
-//Name return name
-func (c *protobufCodec) Name() string {
-       return "protobuf_codec"
-}
diff --git a/proxy/protocol/http/sidecar.go b/proxy/protocol/http/sidecar.go
index 627c39e..a62a00a 100755
--- a/proxy/protocol/http/sidecar.go
+++ b/proxy/protocol/http/sidecar.go
@@ -70,7 +70,7 @@ func preHandler(req *http.Request) *invocation.Invocation {
        inv.Args = req
        inv.Reply = rest.NewResponse()
        inv.Protocol = "rest"
-       inv.URLPathFormat = req.URL.Path
+       inv.URLPath = req.URL.Path
        return inv
 }
 
@@ -88,7 +88,7 @@ func consumerPreHandler(req *http.Request) 
*invocation.Invocation {
        }
        if err := json.Unmarshal([]byte(cseContextStr), &m); err != nil {
                openlog.Debug("unmarshal " + chassisCommon.HeaderXCseContent + 
" header content failed: " + err.Error())
-               m = make(map[string]string, 0)
+               m = make(map[string]string)
        }
        m[chassisCommon.HeaderSourceName] = runtime.ServiceName
        chassisCommon.SetXCSEContext(m, req)
@@ -216,13 +216,14 @@ func RemoteRequestHandler(w http.ResponseWriter, r 
*http.Request) {
 }
 
 func copyChassisResp2HttpResp(w http.ResponseWriter, resp *http.Response) {
-       postProcessResponse(resp)
-       copyHeader(w.Header(), resp.Header)
-       w.WriteHeader(resp.StatusCode)
        if resp == nil {
                openlog.Warn("response is nil because of unknown reason")
                return
        }
+       postProcessResponse(resp)
+       copyHeader(w.Header(), resp.Header)
+       w.WriteHeader(resp.StatusCode)
+
        _, err := io.Copy(w, resp.Body)
        if err != nil {
                openlog.Error("can not copy: " + err.Error())
@@ -313,14 +314,6 @@ func RecordStatus(inv *invocation.Invocation, statusCode 
int) {
        LabelValues := map[string]string{metrics.LServiceName: 
inv.MicroServiceName, metrics.LApp: inv.RouteTags.AppID(), metrics.LVersion: 
inv.RouteTags.Version()}
        metrics.RecordStatus(LabelValues, statusCode)
 }
-func copyHeader(dst, src http.Header) {
-       for k, vs := range src {
-               for _, v := range vs {
-                       dst.Add(k, v)
-               }
-       }
-}
-
 func prepareRequest(req *http.Request) {
        if req.ContentLength == 0 {
                req.Body = nil
@@ -332,6 +325,14 @@ func prepareRequest(req *http.Request) {
 
 }
 
+func copyHeader(dst, src http.Header) {
+       for k, vs := range src {
+               for _, v := range vs {
+                       dst.Add(k, v)
+               }
+       }
+}
+
 func postProcessResponse(rsp *http.Response) {
        rsp.Header.Del("Connection")
 }
diff --git a/scripts/travis/unit_test.sh b/scripts/travis/unit_test.sh
index 16fc504..34e7245 100644
--- a/scripts/travis/unit_test.sh
+++ b/scripts/travis/unit_test.sh
@@ -17,15 +17,4 @@
 
 set -e
 
-echo "mode: atomic" > coverage.txt
-
-for d in $(go list ./... | grep -v vendor); do
-    echo $d
-    cd $GOPATH/src/$d
-    if [ $(ls | grep _test.go | wc -l) -gt 0 ]; then
-        go test -cover -covermode atomic -coverprofile coverage.out
-        if [ -f coverage.out ]; then
-            sed '1d;$d' coverage.out >> 
$GOPATH/src/github.com/apache/servicecomb-mesher/coverage.txt
-        fi
-    fi
-done
\ No newline at end of file
+go test $(go list ./... |  grep -v proxy/pkg/egress | grep -v examples) -cover 
-covermode atomic -coverprofile coverage.out
\ No newline at end of file

Reply via email to