We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
使用时往往会有这样的场景,就是为当前模块创建一个独立的http client, 并且可以初始化一些默认参数 比方说:
defaultHeader := make(http.Header) defaultHeader .Set("APPID", "xxxx") r := req.New("https://api.github.com", defaultHeader) res, _ := r.get("/users")
The text was updated successfully, but these errors were encountered:
req 的特点是轻量,这种场景实际可以自己稍稍封装个Client即可,示例:
package main import ( "github.com/imroc/req" "net/http" ) type Client struct{ *req.Req defaultHeaders http.Header } func NewClient(headers http.Header) *Client { return &Client{ Req: req.New(), defaultHeaders: headers, } } func main() { defaultHeader := make(http.Header) defaultHeader .Set("APPID", "xxxx") c := NewClient(defaultHeader) res, _ := c.Get("http://xxx.com/users") ... }
Sorry, something went wrong.
No branches or pull requests
使用时往往会有这样的场景,就是为当前模块创建一个独立的http client, 并且可以初始化一些默认参数
比方说:
The text was updated successfully, but these errors were encountered: