You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zt...@apache.org on 2021/12/24 01:22:37 UTC

[dubbo-go-pixiu] branch develop updated: Ftr: add default http to dubbo MappingParams (#298)

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

ztelur pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git


The following commit(s) were added to refs/heads/develop by this push:
     new 04933a9  Ftr: add default http to dubbo MappingParams (#298)
04933a9 is described below

commit 04933a95f3cff1fd4788d1f5cb543347a5cb75a5
Author: 氕氘氚 <cj...@163.com>
AuthorDate: Fri Dec 24 09:22:28 2021 +0800

    Ftr: add default http to dubbo MappingParams (#298)
    
    * feat: add default MappingParams function
    
    * docs: add license
    
    * docs: add defaultMappingParams
    
    * docs: dd a switch to use default mapping role
    
    * fix: add Client.dubboProxyConfig nil check in MapParams func
    
    Co-authored-by: Mark4z <36...@users.noreply.github.com>
    Co-authored-by: Xin.Zh <dr...@foxmail.com>
---
 pkg/client/dubbo/config.go                 |  2 ++
 pkg/client/dubbo/{config.go => default.go} | 32 +++++++++++++++++++++++-------
 pkg/client/dubbo/dubbo.go                  |  3 +++
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/pkg/client/dubbo/config.go b/pkg/client/dubbo/config.go
index df7aeee..c1a598b 100644
--- a/pkg/client/dubbo/config.go
+++ b/pkg/client/dubbo/config.go
@@ -27,4 +27,6 @@ type DubboProxyConfig struct {
 	Registries map[string]model.Registry `yaml:"registries" json:"registries"`
 	// Timeout
 	Timeout *model.TimeoutConfig `yaml:"timeout_config" json:"timeout_config"`
+	// IsDefaultMap whether to use DefaultMap role
+	IsDefaultMap bool
 }
diff --git a/pkg/client/dubbo/config.go b/pkg/client/dubbo/default.go
similarity index 58%
copy from pkg/client/dubbo/config.go
copy to pkg/client/dubbo/default.go
index df7aeee..7ceb9e7 100644
--- a/pkg/client/dubbo/config.go
+++ b/pkg/client/dubbo/default.go
@@ -18,13 +18,31 @@
 package dubbo
 
 import (
-	"github.com/apache/dubbo-go-pixiu/pkg/model"
+	"github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
 )
 
-// DubboProxyConfig the config for dubbo proxy
-type DubboProxyConfig struct {
-	// Registries such as zk,nacos or etcd
-	Registries map[string]model.Registry `yaml:"registries" json:"registries"`
-	// Timeout
-	Timeout *model.TimeoutConfig `yaml:"timeout_config" json:"timeout_config"`
+// defaultMappingParams default http to dubbo config
+var defaultMappingParams = []config.MappingParam{
+	{
+		Name:  "requestBody.values",
+		MapTo: "opt.values",
+	}, {
+		Name:  "requestBody.types",
+		MapTo: "opt.types",
+	}, {
+		Name:  "uri.application",
+		MapTo: "opt.application",
+	}, {
+		Name:  "uri.interface",
+		MapTo: "opt.interface",
+	}, {
+		Name:  "queryStrings.method",
+		MapTo: "opt.method",
+	}, {
+		Name:  "queryStrings.group",
+		MapTo: "opt.group",
+	}, {
+		Name:  "queryStrings.version",
+		MapTo: "opt.version",
+	},
 }
diff --git a/pkg/client/dubbo/dubbo.go b/pkg/client/dubbo/dubbo.go
index 5ae7f67..7126472 100644
--- a/pkg/client/dubbo/dubbo.go
+++ b/pkg/client/dubbo/dubbo.go
@@ -223,6 +223,9 @@ func (dc *Client) genericArgs(req *client.Request) (interface{}, error) {
 func (dc *Client) MapParams(req *client.Request) (interface{}, error) {
 	r := req.API.Method.IntegrationRequest
 	values := newDubboTarget(r.MappingParams)
+	if dc.dubboProxyConfig != nil && dc.dubboProxyConfig.IsDefaultMap {
+		values = newDubboTarget(defaultMappingParams)
+	}
 	for _, mappingParam := range r.MappingParams {
 		source, _, err := client.ParseMapSource(mappingParam.Name)
 		if err != nil {