package httpclient import ( "maps" "net/http" ) type ( options struct { url string method string header map[string]string params map[string]string body any human bool client *http.Client } Option func(o *options) ) func WithUrl(s string) Option { return func(o *options) { o.url = s } } func WithMethod(s string) Option { return func(o *options) { o.method = s } } func WithHuman() Option { return func(o *options) { o.human = true } } func WithClient(c *http.Client) Option { return func(o *options) { o.client = c } } func WithHeader(h map[string]string) Option { return func(o *options) { if o.header == nil { o.header = make(map[string]string) } maps.Copy(o.header, h) } } func WithParams(h map[string]string) Option { return func(o *options) { o.params = h } } func WithBody(v any) Option { return func(o *options) { o.body = v } } func newOptions() *options { return &options{ client: DefaultClient, method: http.MethodGet, } }