Skip to content

Commit

Permalink
Ftr: add default http to dubbo MappingParams (#298)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Xin.Zh <[email protected]>
  • Loading branch information
3 people authored Dec 24, 2021
1 parent 300f0e9 commit 04933a9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/client/dubbo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
48 changes: 48 additions & 0 deletions pkg/client/dubbo/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 dubbo

import (
"github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/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",
},
}
3 changes: 3 additions & 0 deletions pkg/client/dubbo/dubbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 04933a9

Please sign in to comment.