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

fix:POST request body is missing #260

Merged
merged 3 commits into from
Oct 1, 2021
Merged

fix:POST request body is missing #260

merged 3 commits into from
Oct 1, 2021

Conversation

baerwang
Copy link
Member

What this PR does:

Which issue(s) this PR fixes:

Fixes #259

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@ztelur
Copy link
Contributor

ztelur commented Sep 28, 2021

Filter struct {
  cfg *Config
  client *http3.Client
}

is this way better ? leave config empty for adding more config property for httpclient further

@@ -51,15 +51,17 @@ type (
cfg *Config
}
// Config describe the config of Filter
Config struct{}
Config struct {
client *http3.Client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应将整个 http.Client 给用户反序列化配置,用户只需要关注 transport 的内容

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想的是把整个http.Client交给用户,http.Clinet 里的其它的配置也许用户需要用呢?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transport 是一个 interface,直接反序列化 client 怎么样知道 transport 反序列化到哪个对象上呢。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我不太明白你说的反序列化client场景的所在的意义,如果以为有这个必要的话,我可以重新提交pr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (fm *FilterManager) Apply(name string, conf map[string]interface{}) (HttpFilter, error) {
	plugin, err := GetHttpFilterPlugin(name)
	if err != nil {
		return nil, errors.New("filter not found")
	}

	filter, err := plugin.CreateFilter()

	if err != nil {
		return nil, errors.New("plugin create filter error")
	}

	factoryConf := filter.Config()
        //filter 的 config 是通过 yaml 反序列化去初始化的。
	if err := yaml.ParseConfig(factoryConf, conf); err != nil {
		return nil, errors.Wrap(err, "config error")
	}
	err = filter.Apply()
	if err != nil {
		return nil, errors.Wrap(err, "create fail")
	}
	return filter, nil
}

见上面代码注释

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,那我把transport放到filter结构体下,保证当前该代码的统一风格,有问题嘛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样应该没问题

@baerwang
Copy link
Member Author

Filter struct {
  cfg *Config
  client *http3.Client
}

这种方式更好吗?将配置留空以进一步为 httpclient 添加更多配置属性

我觉得可以,另外这种还可以保证代码的统一规范

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2021

Codecov Report

Merging #260 (d374a53) into develop (6a282f0) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #260   +/-   ##
========================================
  Coverage    39.75%   39.75%           
========================================
  Files           50       50           
  Lines         2568     2568           
========================================
  Hits          1021     1021           
  Misses        1436     1436           
  Partials       111      111           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a282f0...d374a53. Read the comment docs.

@ztelur ztelur requested a review from AlexStocks September 29, 2021 08:23
@ztelur ztelur merged commit 7e8add1 into apache:develop Oct 1, 2021
@ztelur ztelur added this to the v0.4.0 milestone Oct 20, 2021
mark4z pushed a commit that referenced this pull request Nov 7, 2021
* fix:POST request body is missing

* Let users care about http.Client transport and keep a uniform code style

Co-authored-by: randy <ztelur@gmail.com>
Former-commit-id: 7e8add1
tydhot pushed a commit to tydhot/dubbo-go-pixiu that referenced this pull request Nov 10, 2021
* fix:POST request body is missing

* Let users care about http.Client transport and keep a uniform code style

Co-authored-by: randy <ztelur@gmail.com>
Former-commit-id: 79e6b3f [formerly 7e8add1]
Former-commit-id: c30094c
bobtthp pushed a commit to bobtthp/dubbo-go-pixiu that referenced this pull request Dec 12, 2022
* fix:POST request body is missing

* Let users care about http.Client transport and keep a uniform code style

Co-authored-by: randy <ztelur@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POST请求body丢失问题
8 participants