Skip to content

Commit

Permalink
Merge pull request #456 from mark4z/develop
Browse files Browse the repository at this point in the history
Remove "Types" on Http to dubbo proxy
  • Loading branch information
AlexStocks authored Jul 25, 2022
2 parents 751108b + ffb7242 commit 8f61561
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Shopify/sarama v1.19.0
github.com/alibaba/sentinel-golang v1.0.4
github.com/apache/dubbo-getty v1.4.8
github.com/apache/dubbo-go-hessian2 v1.11.0
github.com/apache/dubbo-go-hessian2 v1.11.1
github.com/cch123/supermonkey v1.0.1
github.com/creasty/defaults v1.5.2
github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/Av
github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/dubbo-go-hessian2 v1.11.0 h1:VTdT6NStuEqNmyT3AdSN2DLDBqhXvAAyAAAoh9hLavk=
github.com/apache/dubbo-go-hessian2 v1.11.0/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w=
github.com/apache/dubbo-go-hessian2 v1.11.1-0.20220704061226-83d6845c8183 h1:lqz0mmcsg1oMJnSjMyfDoMt6cs7yXTCRUqgmgNHVJNo=
github.com/apache/dubbo-go-hessian2 v1.11.1-0.20220704061226-83d6845c8183/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
Expand Down
9 changes: 5 additions & 4 deletions pkg/common/constant/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ const (
)

const (
DubboHttpDubboVersion = "x-dubbo-http1.1-dubbo-version"
DubboServiceProtocol = "x-dubbo-service-protocol"
DubboServiceVersion = "x-dubbo-service-version"
DubboGroup = "x-dubbo-service-group"
DubboHttpDubboVersion = "x-dubbo-http1.1-dubbo-version"
DubboServiceProtocol = "x-dubbo-service-protocol"
DubboServiceVersion = "x-dubbo-service-version"
DubboGroup = "x-dubbo-service-group"
DubboServiceMethodTypes = "x-dubbo-service-method-overloading"
)
20 changes: 6 additions & 14 deletions pkg/filter/http/dubboproxy/dubbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,8 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus {
interfaceKey := service

groupKey := hc.Request.Header.Get(constant.DubboGroup)
if groupKey == "" {
groupKey = "default"
}
versionKey := hc.Request.Header.Get(constant.DubboServiceVersion)
if versionKey == "" {
versionKey = "1.0.0"
}
types := hc.Request.Header.Get(constant.DubboServiceMethodTypes)

rawBody, err := ioutil.ReadAll(hc.Request.Body)
if err != nil {
Expand All @@ -150,8 +145,8 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus {
return filter.Stop
}

mapBody := map[string]interface{}{}
if err := json.Unmarshal(rawBody, &mapBody); err != nil {
var body interface{}
if err := json.Unmarshal(rawBody, &body); err != nil {
logger.Infof("[dubbo-go-pixiu] unmarshal request body error %v", err)
bt, _ := json.Marshal(pixiuHttp.ErrResponse{Message: fmt.Sprintf("unmarshal request body error %v", err)})
hc.SendLocalReply(http.StatusBadRequest, bt)
Expand All @@ -167,14 +162,11 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus {
valuesList []hessian.Object
)

types := mapBody["types"]
if typesString, ok := types.(string); ok {
typesList = strings.Split(typesString, ",")
} else if _, ok = types.([]string); ok {
typesList = types.([]string)
if types != "" {
typesList = strings.Split(types, ",")
}

values := mapBody["values"]
values := body
if _, ok := values.([]interface{}); ok {
for _, v := range values.([]interface{}) {
valuesList = append(valuesList, v)
Expand Down

0 comments on commit 8f61561

Please sign in to comment.