Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Types" on Http to dubbo proxy #456

Merged
merged 3 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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