A chainable Go HTTP library for streamlined request and response management.
English | 中文简体
go get github.com/chenmingyong0423/go-http-chain
// Create a new default client and set global Header parameters for the client
client := httpchain.NewDefault().SetHeader("X-Global-Param", "go-http-chain")
// Create a Request specifying a GET request; the client's Headers and Query parameters will be passed to this Request
// Retrieve the *http.Response
resp, err := client.Get("localhost:8080/test").
SetHeader("name", "Mingyong Chen").
SetQuery("name", "Mingyong Chen").
Call(context.Background()).Result()
// Directly parse the response result into a specified struct
var result map[string]any
err = client.Get("localhost:8080/test").
SetHeader("name", "Mingyong Chen").
SetQuery("name", "Mingyong Chen").
Call(context.Background()).DecodeRespBody(&result)