Repository: go-kratos/kratos
Pull request #2284 (2022-08-17 01:29:35)

fix typo in transport/http/context.go
fix typo in transport/http/context.go

codecov-commenter: # [Codecov](https://codecov.io/gh/go-kratos/kratos/pull/2284?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) Report
> Merging [#2284](https://codecov.io/gh/go-kratos/kratos/pull/2284?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (91bcb92) into [main](https://codecov.io/gh/go-kratos/kratos/commit/2d206076f88c1f9a85f4bd353cdfca8e4000896d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (2d20607) will **decrease** coverage by `0.05%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main    #2284      +/-   ##
==========================================
- Coverage   85.17%   85.11%   -0.06%     
==========================================
  Files          88       88              
  Lines        3783     3783              
==========================================
- Hits         3222     3220       -2     
- Misses        389      391       +2     
  Partials      172      172              
```


| [Impacted Files](https://codecov.io/gh/go-kratos/kratos/pull/2284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) | Coverage Δ | |
|---|---|---|
| [transport/http/context.go](https://codecov.io/gh/go-kratos/kratos/pull/2284/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos#diff-dHJhbnNwb3J0L2h0dHAvY29udGV4dC5nbw==) | `93.02% <100.00%> (ø)` | |
| [internal/context/context.go](https://codecov.io/gh/go-kratos/kratos/pull/2284/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos#diff-aW50ZXJuYWwvY29udGV4dC9jb250ZXh0Lmdv) | `97.01% <0.00%> (-2.99%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)


Patch:
diff --git a/cmd/kratos/version.go b/cmd/kratos/version.go
index 50708a15..9d205cbc 100644
--- a/cmd/kratos/version.go
+++ b/cmd/kratos/version.go
@@ -1,4 +1,4 @@
 package main
 
 // release is the current kratos tool version.
-const release = "v2.4.1"
+const release = "v2.5.0"
diff --git a/cmd/protoc-gen-go-errors/version.go b/cmd/protoc-gen-go-errors/version.go
index 14ef3ee0..71fced3e 100644
--- a/cmd/protoc-gen-go-errors/version.go
+++ b/cmd/protoc-gen-go-errors/version.go
@@ -1,4 +1,4 @@
 package main
 
 // release is the current protoc-gen-go-errors version.
-const release = "v2.4.1"
+const release = "v2.5.0"
diff --git a/cmd/protoc-gen-go-http/version.go b/cmd/protoc-gen-go-http/version.go
index 36a83f84..065e7dd5 100644
--- a/cmd/protoc-gen-go-http/version.go
+++ b/cmd/protoc-gen-go-http/version.go
@@ -1,4 +1,4 @@
 package main
 
 // release is the current protoc-gen-go-http version.
-const release = "v2.4.1"
+const release = "v2.5.0"
diff --git a/contrib/config/apollo/apollo.go b/contrib/config/apollo/apollo.go
index a0a38b02..5f868bab 100644
--- a/contrib/config/apollo/apollo.go
+++ b/contrib/config/apollo/apollo.go
@@ -7,7 +7,10 @@ import (
 	"github.com/go-kratos/kratos/v2/log"
 
 	"github.com/apolloconfig/agollo/v4"
+	"github.com/apolloconfig/agollo/v4/constant"
 	apolloConfig "github.com/apolloconfig/agollo/v4/env/config"
+	"github.com/apolloconfig/agollo/v4/extension"
+	"github.com/go-kratos/kratos/v2/encoding"
 )
 
 type apollo struct {
@@ -15,6 +18,13 @@ type apollo struct {
 	opt    *options
 }
 
+const (
+	yaml       = "yaml"
+	yml        = "yml"
+	json       = "json"
+	properties = "properties"
+)
+
 // Option is apollo option
 type Option func(*options)
 
@@ -26,6 +36,7 @@ type options struct {
 	namespace      string
 	isBackupConfig bool
 	backupPath     string
+	originConfig   bool
 }
 
 // WithAppID with apollo config app id
@@ -84,6 +95,16 @@ func WithBackupPath(backupPath string) Option {
 	}
 }
 
+// WithOriginalConfig use the original configuration file without parse processing
+func WithOriginalConfig() Option {
+	return func(o *options) {
+		extension.AddFormatParser(constant.JSON, &jsonExtParser{})
+		extension.AddFormatParser(constant.YAML, &yamlExtParser{})
+		extension.AddFormatParser(constant.YML, &yamlExtParser{})
+		o.originConfig = true
+	}
+}
+
 func NewSource(opts ...Option) config.Source {
 	op := options{}
 	for _, o := range opts {
@@ -108,31 +129,78 @@ func NewSource(opts ...Option) config.Source {
 
 func format(ns string) string {
 	arr := strings.Split(ns, ".")
-	if len(arr) <= 1 {
-		return "json"
+	if len(arr) <= 1 || arr[len(arr)-1] == properties {
+		return json
 	}
-
 	return arr[len(arr)-1]
 }
 
 func (e *apollo) load() []*config.KeyValue {
-	kv := make([]*config.KeyValue, 0)
+	kvs := make([]*config.KeyValue, 0)
 	namespaces := strings.Split(e.opt.namespace, ",")
 
 	for _, ns := range namespaces {
-		value, err := e.client.GetConfigCache(ns).Get("content")
-		if err != nil {
-			log.Warnw("apollo get config failed", "err", err)
+		if !e.opt.originConfig {
+			kv, err := e.getConfig(ns)
+			if err != nil {
+				log.Errorf("apollo get config failed，err:%v", err)
+				continue
+			}
+			kvs = append(kvs, kv)
+			continue
 		}
-		// serialize the namespace content KeyValue into bytes.
-		kv = append(kv, &config.KeyValue{
-			Key:    ns,
-			Value:  []byte(value.(string)),
-			Format: format(ns),
-		})
+		if strings.Contains(ns, ".") && !strings.Contains(ns, properties) &&
+			(format(ns) == yaml || format(ns) == yml || format(ns) == json) {
+			kv, err := e.getOriginConfig(ns)
+			if err != nil {
+				log.Errorf("apollo get config failed，err:%v", err)
+				continue
+			}
+			kvs = append(kvs, kv)
+			continue
+		} else {
+			kv, err := e.getConfig(ns)
+			if err != nil {
+				log.Errorf("apollo get config failed，err:%v", err)
+				continue
+			}
+			kvs = append(kvs, kv)
+		}
+	}
+	return kvs
+}
+
+func (e *apollo) getConfig(ns string) (*config.KeyValue, error) {
+	next := map[string]interface{}{}
+	e.client.GetConfigCache(ns).Range(func(key, value interface{}) bool {
+		// all values are out properties format
+		resolve(genKey(ns, key.(string)), value, next)
+		return true
+	})
+	f := format(ns)
+	codec := encoding.GetCodec(f)
+	val, err := codec.Marshal(next)
+	if err != nil {
+		return nil, err
 	}
+	return &config.KeyValue{
+		Key:    ns,
+		Value:  val,
+		Format: f,
+	}, nil
+}
 
-	return kv
+func (e apollo) getOriginConfig(ns string) (*config.KeyValue, error) {
+	value, err := e.client.GetConfigCache(ns).Get("content")
+	if err != nil {
+		return nil, err
+	}
+	// serialize the namespace content KeyValue into bytes.
+	return &config.KeyValue{
+		Key:    ns,
+		Value:  []byte(value.(string)),
+		Format: format(ns),
+	}, nil
 }
 
 func (e *apollo) Load() (kv []*config.KeyValue, err error) {
@@ -146,3 +214,54 @@ func (e *apollo) Watch() (config.Watcher, error) {
 	}
 	return w, nil
 }
+
+// resolve convert kv pair into one map[string]interface{} by split key into different
+// map level. such as: app.name = "application" => map[app][name] = "application"
+func resolve(key string, value interface{}, target map[string]interface{}) {
+	// expand key "aaa.bbb" into map[aaa]map[bbb]interface{}
+	keys := strings.Split(key, ".")
+	last := len(keys) - 1
+	cursor := target
+
+	for i, k := range keys {
+		if i == last {
+			cursor[k] = value
+			break
+		}
+
+		// not the last key, be deeper
+		v, ok := cursor[k]
+		if !ok {
+			// create a new map
+			deeper := make(map[string]interface{})
+			cursor[k] = deeper
+			cursor = deeper
+			continue
+		}
+
+		// current exists, then check existing value type, if it's not map
+		// that means duplicate keys, and at least one is not map instance.
+		if cursor, ok = v.(map[string]interface{}); !ok {
+			log.Warnf("duplicate key: %v\n", strings.Join(keys[:i+1], "."))
+			break
+		}
+	}
+}
+
+// genKey got the key of config.KeyValue pair.
+// eg: namespace.ext with subKey got namespace.subKey
+func genKey(ns, sub string) string {
+	arr := strings.Split(ns, ".")
+	if len(arr) < 1 {
+		return sub
+	}
+
+	if len(arr) == 1 {
+		if ns == "" {
+			return sub
+		}
+		return ns + "." + sub
+	}
+
+	return strings.Join(arr[:len(arr)-1], ".") + "." + sub
+}
diff --git a/contrib/config/apollo/parser.go b/contrib/config/apollo/parser.go
index a449256f..2b1abb99 100644
--- a/contrib/config/apollo/parser.go
+++ b/contrib/config/apollo/parser.go
@@ -1,10 +1,5 @@
 package apollo
 
-import (
-	"github.com/apolloconfig/agollo/v4/constant"
-	"github.com/apolloconfig/agollo/v4/extension"
-)
-
 type jsonExtParser struct{}
 
 func (parser jsonExtParser) Parse(configContent interface{}) (map[string]interface{}, error) {
@@ -13,13 +8,6 @@ func (parser jsonExtParser) Parse(configContent interface{}) (map[string]interfa
 
 type yamlExtParser struct{}
 
-func (parser yamlExtParser) Parse(configContent interface{}) (out map[string]interface{}, err error) {
+func (parser yamlExtParser) Parse(configContent interface{}) (map[string]interface{}, error) {
 	return map[string]interface{}{"content": configContent}, nil
 }
-
-func init() {
-	// add json/yaml/yml format
-	extension.AddFormatParser(constant.JSON, &jsonExtParser{})
-	extension.AddFormatParser(constant.YAML, &yamlExtParser{})
-	extension.AddFormatParser(constant.YML, &yamlExtParser{})
-}
diff --git a/contrib/config/apollo/watcher.go b/contrib/config/apollo/watcher.go
index 8c039005..670139a2 100644
--- a/contrib/config/apollo/watcher.go
+++ b/contrib/config/apollo/watcher.go
@@ -2,6 +2,9 @@ package apollo
 
 import (
 	"context"
+	"strings"
+
+	"github.com/go-kratos/kratos/v2/encoding"
 
 	"github.com/go-kratos/kratos/v2/config"
 	"github.com/go-kratos/kratos/v2/log"
@@ -23,14 +26,38 @@ type customChangeListener struct {
 
 func (c *customChangeListener) onChange(namespace string, changes map[string]*storage.ConfigChange) []*config.KeyValue {
 	kv := make([]*config.KeyValue, 0, 2)
-	value, err := c.apollo.client.GetConfigCache(namespace).Get("content")
+	if strings.Contains(namespace, ".") && !strings.Contains(namespace, properties) &&
+		(format(namespace) == yaml || format(namespace) == yml || format(namespace) == json) {
+		value, err := c.apollo.client.GetConfigCache(namespace).Get("content")
+		if err != nil {
+			log.Warnw("apollo get config failed", "err", err)
+		}
+		kv = append(kv, &config.KeyValue{
+			Key:    namespace,
+			Value:  []byte(value.(string)),
+			Format: format(namespace),
+		})
+
+		return kv
+	}
+
+	next := make(map[string]interface{})
+
+	for key, change := range changes {
+		resolve(genKey(namespace, key), change.NewValue, next)
+	}
+
+	f := format(namespace)
+	codec := encoding.GetCodec(f)
+	val, err := codec.Marshal(next)
 	if err != nil {
-		log.Warnw("apollo get config failed", "err", err)
+		log.Warnf("apollo could not handle namespace %s: %v", namespace, err)
+		return nil
 	}
 	kv = append(kv, &config.KeyValue{
 		Key:    namespace,
-		Value:  []byte(value.(string)),
-		Format: format(namespace),
+		Value:  val,
+		Format: f,
 	})
 
 	return kv
diff --git a/contrib/encoding/msgpack/go.mod b/contrib/encoding/msgpack/go.mod
index 9e02ad81..5d78c21b 100644
--- a/contrib/encoding/msgpack/go.mod
+++ b/contrib/encoding/msgpack/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/encoding/msgpack/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/vmihailenco/msgpack/v5 v5.3.5
 )
 
diff --git a/contrib/log/aliyun/go.mod b/contrib/log/aliyun/go.mod
index 83b139ea..efe1b827 100644
--- a/contrib/log/aliyun/go.mod
+++ b/contrib/log/aliyun/go.mod
@@ -4,7 +4,7 @@ go 1.16
 
 require (
 	github.com/aliyun/aliyun-log-go-sdk v0.1.37
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	google.golang.org/protobuf v1.28.1
 )
 
diff --git a/contrib/log/fluent/go.mod b/contrib/log/fluent/go.mod
index b8477bde..b316425a 100644
--- a/contrib/log/fluent/go.mod
+++ b/contrib/log/fluent/go.mod
@@ -5,7 +5,7 @@ go 1.16
 require (
 	github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
 	github.com/fluent/fluent-logger-golang v1.9.0
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/kr/pretty v0.3.0 // indirect
 	github.com/tinylib/msgp v1.1.6 // indirect
 )
diff --git a/contrib/log/logrus/go.mod b/contrib/log/logrus/go.mod
index fa3989f3..aa1f5946 100644
--- a/contrib/log/logrus/go.mod
+++ b/contrib/log/logrus/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/log/logrus/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/sirupsen/logrus v1.8.1
 	github.com/stretchr/testify v1.7.1
 )
diff --git a/contrib/log/tencent/go.mod b/contrib/log/tencent/go.mod
index feb39f17..2d3fa7dc 100644
--- a/contrib/log/tencent/go.mod
+++ b/contrib/log/tencent/go.mod
@@ -3,7 +3,9 @@ module github.com/go-kratos/kratos/contrib/log/tencent/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.2
 	google.golang.org/protobuf v1.28.0
 )
+
+replace github.com/go-kratos/kratos/v2 => ../../../
diff --git a/contrib/log/tencent/go.sum b/contrib/log/tencent/go.sum
index b4b87442..993b044f 100644
--- a/contrib/log/tencent/go.sum
+++ b/contrib/log/tencent/go.sum
@@ -27,8 +27,6 @@ github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09
 github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/go-kratos/aegis v0.1.2/go.mod h1:jYeSQ3Gesba478zEnujOiG5QdsyF3Xk/8owFUeKcHxw=
-github.com/go-kratos/kratos/v2 v2.4.1 h1:NFQy8Ha4Xu6T3Q40JlKzspvlMa5IGvIHhJw5+sqyV4c=
-github.com/go-kratos/kratos/v2 v2.4.1/go.mod h1:5acyLj4EgY428AJnZl2EwCrMV1OVlttQFBum+SghMiA=
 github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
diff --git a/contrib/log/zap/go.mod b/contrib/log/zap/go.mod
index 8d5d2c7e..ecb315e1 100644
--- a/contrib/log/zap/go.mod
+++ b/contrib/log/zap/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/log/zap/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	go.uber.org/zap v1.21.0
 )
 
diff --git a/contrib/metrics/datadog/go.mod b/contrib/metrics/datadog/go.mod
index 4d06c42c..206ccf4e 100644
--- a/contrib/metrics/datadog/go.mod
+++ b/contrib/metrics/datadog/go.mod
@@ -5,7 +5,7 @@ go 1.16
 require (
 	github.com/DataDog/datadog-go v4.8.3+incompatible
 	github.com/Microsoft/go-winio v0.5.2 // indirect
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 )
 
 replace github.com/go-kratos/kratos/v2 => ../../../
diff --git a/contrib/metrics/prometheus/go.mod b/contrib/metrics/prometheus/go.mod
index ff2f8af2..c6a1b5df 100644
--- a/contrib/metrics/prometheus/go.mod
+++ b/contrib/metrics/prometheus/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/metrics/prometheus/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/prometheus/client_golang v1.12.2
 	github.com/prometheus/common v0.37.0
 )
diff --git a/contrib/opensergo/go.mod b/contrib/opensergo/go.mod
index fa64c2ca..beba8f7f 100644
--- a/contrib/opensergo/go.mod
+++ b/contrib/opensergo/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/opensergo/v2
 go 1.17
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/opensergo/opensergo-go v0.0.0-20220331070310-e5b01fee4d1c
 	golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
 	google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod
index 03ed997f..368308ec 100644
--- a/contrib/registry/consul/go.mod
+++ b/contrib/registry/consul/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/consul/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/hashicorp/consul/api v1.13.1
 )
 
diff --git a/contrib/registry/discovery/go.mod b/contrib/registry/discovery/go.mod
index f03c2f15..407af47a 100644
--- a/contrib/registry/discovery/go.mod
+++ b/contrib/registry/discovery/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/discovery/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/go-resty/resty/v2 v2.7.0
 	github.com/pkg/errors v0.9.1
 )
diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod
index 6634eac7..952e8a55 100644
--- a/contrib/registry/etcd/go.mod
+++ b/contrib/registry/etcd/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/etcd/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	go.etcd.io/etcd/client/v3 v3.5.4
 	google.golang.org/grpc v1.46.2
 )
diff --git a/contrib/registry/kubernetes/go.mod b/contrib/registry/kubernetes/go.mod
index 67dd4504..cad07df0 100644
--- a/contrib/registry/kubernetes/go.mod
+++ b/contrib/registry/kubernetes/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/kubernetes/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/json-iterator/go v1.1.12
 	k8s.io/api v0.24.3
 	k8s.io/apimachinery v0.24.3
diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod
index a4665a10..bdfd037e 100644
--- a/contrib/registry/nacos/go.mod
+++ b/contrib/registry/nacos/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/nacos/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/nacos-group/nacos-sdk-go v1.0.9
 )
 
diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod
index e399d9dd..2789a991 100644
--- a/contrib/registry/polaris/go.mod
+++ b/contrib/registry/polaris/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/polaris/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/polarismesh/polaris-go v1.1.0
 )
 
diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod
index d8d58818..a149d20a 100644
--- a/contrib/registry/zookeeper/go.mod
+++ b/contrib/registry/zookeeper/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/registry/zookeeper/v2
 go 1.16
 
 require (
-	github.com/go-kratos/kratos/v2 v2.4.1
+	github.com/go-kratos/kratos/v2 v2.5.0
 	github.com/go-zookeeper/zk v1.0.3
 	golang.org/x/sync v0.0.0-20220513210516-0976fa681c29
 )
diff --git a/internal/endpoint/endpoint.go b/internal/endpoint/endpoint.go
index e4c9ef96..160b694f 100644
--- a/internal/endpoint/endpoint.go
+++ b/internal/endpoint/endpoint.go
@@ -2,7 +2,6 @@ package endpoint
 
 import (
 	"net/url"
-	"strconv"
 )
 
 // NewEndpoint new an Endpoint URL.
@@ -18,10 +17,6 @@ func ParseEndpoint(endpoints []string, scheme string) (string, error) {
 			return "", err
 		}
 
-		// TODO: Compatibility processing
-		// Function is to convert grpc:/127.0.0.1/?isSecure=true into grpcs:/127.0.0.1/
-		// It will be deleted in about a month
-		u = legacyURLToNew(u)
 		if u.Scheme == scheme {
 			return u.Host, nil
 		}
@@ -29,27 +24,6 @@ func ParseEndpoint(endpoints []string, scheme string) (string, error) {
 	return "", nil
 }
 
-func legacyURLToNew(u *url.URL) *url.URL {
-	if u.Scheme == "https" || u.Scheme == "grpcs" {
-		return u
-	}
-	if IsSecure(u) {
-		return &url.URL{Scheme: u.Scheme + "s", Host: u.Host}
-	}
-	return u
-}
-
-// IsSecure parses isSecure for Endpoint URL.
-// Note: It will be deleted after some time,
-// unified use grpcs://127.0.0.1:8080 instead of grpc://127.0.0.1:8080?isSecure=true
-func IsSecure(u *url.URL) bool {
-	ok, err := strconv.ParseBool(u.Query().Get("isSecure"))
-	if err != nil {
-		return false
-	}
-	return ok
-}
-
 // Scheme is the scheme of endpoint url.
 // examples: scheme="http",isSecure=true get "https"
 func Scheme(scheme string, isSecure bool) string {
diff --git a/transport/http/context.go b/transport/http/context.go
index 347d93ff..f65e03fb 100644
--- a/transport/http/context.go
+++ b/transport/http/context.go
@@ -46,7 +46,7 @@ type responseWriter struct {
 	w    http.ResponseWriter
 }
 
-func (w *responseWriter) rest(res http.ResponseWriter) {
+func (w *responseWriter) reset(res http.ResponseWriter) {
 	w.w = res
 	w.code = http.StatusOK
 }
@@ -151,7 +151,7 @@ func (c *wrapper) Stream(code int, contentType string, rd io.Reader) error {
 }
 
 func (c *wrapper) Reset(res http.ResponseWriter, req *http.Request) {
-	c.w.rest(res)
+	c.w.reset(res)
 	c.res = res
 	c.req = req
 }
diff --git a/version.go b/version.go
index 08f05950..d0afa603 100644
--- a/version.go
+++ b/version.go
@@ -1,4 +1,4 @@
 package kratos
 
 // Release is the current kratos version.
-const Release = "v2.4.1"
+const Release = "v2.5.0"


Test patch:
diff --git a/internal/endpoint/endpoint_test.go b/internal/endpoint/endpoint_test.go
index e8870c80..c02878fd 100644
--- a/internal/endpoint/endpoint_test.go
+++ b/internal/endpoint/endpoint_test.go
@@ -6,41 +6,6 @@ import (
 	"testing"
 )
 
-func TestEndPoint(t *testing.T) {
-	type args struct {
-		url *url.URL
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{
-			name: "grpc://127.0.0.1?isSecure=false",
-			args: args{&url.URL{Scheme: "grpc", Host: "127.0.0.1", RawQuery: "isSecure=false"}},
-			want: false,
-		},
-		{
-			name: "grpc://127.0.0.1?isSecure=true",
-			args: args{&url.URL{Scheme: "grpc", Host: "127.0.0.1", RawQuery: "isSecure=true"}},
-			want: true,
-		},
-		{
-			name: "grpc://127.0.0.1",
-			args: args{&url.URL{Scheme: "grpc", Host: "127.0.0.1"}},
-			want: false,
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IsSecure(tt.args.url); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("GetQuery() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
 func TestNewEndpoint(t *testing.T) {
 	type args struct {
 		scheme string
@@ -111,20 +76,6 @@ func TestParseEndpoint(t *testing.T) {
 			want:    "",
 			wantErr: false,
 		},
-
-		// Legacy
-		{
-			name:    "google",
-			args:    args{endpoints: []string{"grpc://www.google.com/?isSecure=true"}, scheme: "grpcs"},
-			want:    "www.google.com",
-			wantErr: false,
-		},
-		{
-			name:    "baidu",
-			args:    args{endpoints: []string{"http://www.baidu.com/?isSecure=true"}, scheme: "https"},
-			want:    "www.baidu.com",
-			wantErr: false,
-		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -140,56 +91,6 @@ func TestParseEndpoint(t *testing.T) {
 	}
 }
 
-func TestIsSecure(t *testing.T) {
-	tests := []struct {
-		url  *url.URL
-		want bool
-	}{
-		{
-			url:  &url.URL{Scheme: "http", Host: "127.0.0.1"},
-			want: false,
-		},
-		{
-			url:  &url.URL{Scheme: "http", Host: "127.0.0.1", RawQuery: "isSecure=false"},
-			want: false,
-		},
-		{
-			url:  &url.URL{Scheme: "grpc", Host: "127.0.0.1", RawQuery: "isSecure=true"},
-			want: true,
-		},
-	}
-	for _, tt := range tests {
-		if got := IsSecure(tt.url); got != tt.want {
-			t.Errorf("IsSecure() = %v, want %v", got, tt.want)
-		}
-	}
-}
-
-func TestLegacyURLToNew(t *testing.T) {
-	tests := []struct {
-		url  *url.URL
-		want *url.URL
-	}{
-		{
-			url:  &url.URL{Scheme: "http", Host: "www.google.com", RawQuery: "isSecure=true"},
-			want: &url.URL{Scheme: "https", Host: "www.google.com"},
-		},
-		{
-			url:  &url.URL{Scheme: "https", Host: "www.google.com", RawQuery: "isSecure=true"},
-			want: &url.URL{Scheme: "https", Host: "www.google.com", RawQuery: "isSecure=true"},
-		},
-		{
-			url:  &url.URL{Scheme: "http", Host: "go-kratos.dev", RawQuery: "isSecure=false"},
-			want: &url.URL{Scheme: "http", Host: "go-kratos.dev", RawQuery: "isSecure=false"},
-		},
-	}
-	for _, tt := range tests {
-		if got := legacyURLToNew(tt.url); !reflect.DeepEqual(got, tt.want) {
-			t.Errorf("legacyURLToNew() = %v, want %v", got, tt.want)
-		}
-	}
-}
-
 func TestSchema(t *testing.T) {
 	tests := []struct {
 		schema string