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

feat: initialize client && request #1

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

ViolaPioggia
Copy link
Member

What type of PR is this?

feat

Check the PR title.

feat: initialize client && request

@CLAassistant
Copy link

CLAassistant commented May 11, 2024

CLA assistant check
All committers have signed the CLA.

client.go Outdated
}

func New() *Client {
c, _ := client.NewClient()
Copy link

Choose a reason for hiding this comment

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

能把 err 返回出去吗?或者再搞个 mustNew,有error 就 panic

Copy link
Member Author

Choose a reason for hiding this comment

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

OK

return c
}

func (c *Client) SetQueryString(query string) *Client {
Copy link

Choose a reason for hiding this comment

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

没实现的地方可以记个 todo

Copy link
Member Author

Choose a reason for hiding this comment

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

SetQueryString 可以给个示例用法吗

Copy link

Choose a reason for hiding this comment

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

SetQueryString() 是 hertz Request 的原始 API,可以直接转换一下就行https://github.com/cloudwego/hertz/blob/develop/pkg/protocol/request.go#L457

return c
}

func (c *Client) SetHeader(header, value string) *Client {
Copy link

Choose a reason for hiding this comment

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

有些 header 有 k-[]v的形式,包括上面的query,可以考虑支持下这种数组类型

client *client.Client
}

type (
Copy link

Choose a reason for hiding this comment

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

middleware 可以不用支持, hertz client 本身就有 mw 能力,可以把 hertz client mw 以配置的形式注入,就别在 封装的这一层再搞一层 Middleware 了

Copy link

@FGYFFFF FGYFFFF May 23, 2024

Choose a reason for hiding this comment

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

看了下面这个 Middleware 是在用来创建 hertz 的 Request;这块进行不要对外暴露就好,保证easy_http 内部可用就好

client.go Outdated

}

func (c *Client) SetXFormData() *Client {
Copy link

Choose a reason for hiding this comment

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

为啥是 SetXFormData? 多个X?

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.

None yet

4 participants