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

docs: add docs for new client #2991

Merged
merged 15 commits into from
May 13, 2024
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *Client) JSONMarshal() utils.JSONMarshal {
return c.jsonMarshal
}

// SetJSONMarshal Set json encoder.
// SetJSONMarshal sets the JSON encoder.
func (c *Client) SetJSONMarshal(f utils.JSONMarshal) *Client {
c.jsonMarshal = f
return c
Expand Down Expand Up @@ -475,7 +475,7 @@ func (c *Client) Debug() *Client {
return c
}

// DisableDebug disenable log debug level output.
// DisableDebug disables log debug level output.
func (c *Client) DisableDebug() *Client {
c.debug = false
return c
Expand Down Expand Up @@ -574,7 +574,7 @@ func (c *Client) Logger() log.CommonLogger {
return c.logger
}

// Reset clear Client object
// Reset clears the Client object
func (c *Client) Reset() {
c.fasthttp = &fasthttp.Client{}
c.baseURL = ""
Expand Down
33 changes: 14 additions & 19 deletions client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,36 +121,33 @@ func (r *Request) SetContext(ctx context.Context) *Request {
}

// Header method returns header value via key,
// this method will visit all field in the header,
// then sort them.
// this method will visit all field in the header.
func (r *Request) Header(key string) []string {
return r.header.PeekMultiple(key)
}

// AddHeader method adds a single header field and its value in the request instance.
// It will override header which set in client instance.
func (r *Request) AddHeader(key, val string) *Request {
r.header.Add(key, val)
return r
}

// SetHeader method sets a single header field and its value in the request instance.
// It will override header which set in client instance.
// It will override header which has been set in client instance.
func (r *Request) SetHeader(key, val string) *Request {
r.header.Del(key)
r.header.Set(key, val)
return r
}

// AddHeaders method adds multiple header fields and its values at one go in the request instance.
// It will override header which set in client instance.
func (r *Request) AddHeaders(h map[string][]string) *Request {
r.header.AddHeaders(h)
return r
}

// SetHeaders method sets multiple header fields and its values at one go in the request instance.
// It will override header which set in client instance.
// It will override header which has been set in client instance.
func (r *Request) SetHeaders(h map[string]string) *Request {
r.header.SetHeaders(h)
return r
Expand All @@ -169,35 +166,33 @@ func (r *Request) Param(key string) []string {
}

// AddParam method adds a single param field and its value in the request instance.
// It will override param which set in client instance.
func (r *Request) AddParam(key, val string) *Request {
r.params.Add(key, val)
return r
}

// SetParam method sets a single param field and its value in the request instance.
// It will override param which set in client instance.
// It will override param which has been set in client instance.
func (r *Request) SetParam(key, val string) *Request {
r.params.Set(key, val)
return r
}

// AddParams method adds multiple param fields and its values at one go in the request instance.
// It will override param which set in client instance.
func (r *Request) AddParams(m map[string][]string) *Request {
r.params.AddParams(m)
return r
}

// SetParams method sets multiple param fields and its values at one go in the request instance.
// It will override param which set in client instance.
// It will override param which has been set in client instance.
func (r *Request) SetParams(m map[string]string) *Request {
r.params.SetParams(m)
return r
}

// SetParamsWithStruct method sets multiple param fields and its values at one go in the request instance.
// It will override param which set in client instance.
// It will override param which has been set in client instance.
func (r *Request) SetParamsWithStruct(v any) *Request {
r.params.SetParamsWithStruct(v)
return r
Expand All @@ -217,7 +212,7 @@ func (r *Request) UserAgent() string {
}

// SetUserAgent method sets user agent in request.
// It will override user agent which set in client instance.
// It will override user agent which has been set in client instance.
func (r *Request) SetUserAgent(ua string) *Request {
r.userAgent = ua
return r
Expand Down Expand Up @@ -326,14 +321,14 @@ func (r *Request) ResetPathParams() *Request {
return r
}

// SetJSON method sets json body in request.
// SetJSON method sets JSON body in request.
func (r *Request) SetJSON(v any) *Request {
r.body = v
r.bodyType = jsonBody
return r
}

// SetXML method sets xml body in request.
// SetXML method sets XML body in request.
func (r *Request) SetXML(v any) *Request {
r.body = v
r.bodyType = xmlBody
Expand Down Expand Up @@ -589,7 +584,7 @@ func (h *Header) PeekMultiple(key string) []string {
return res
}

// AddHeaders receive a map and add each value to header.
// AddHeaders receives a map and add each value to header.
func (h *Header) AddHeaders(r map[string][]string) {
for k, v := range r {
for _, vv := range v {
Expand Down Expand Up @@ -678,14 +673,14 @@ func (c Cookie) VisitAll(f func(key, val string)) {
}
}

// Reset clear the Cookie object.
// Reset clears the Cookie object.
func (c Cookie) Reset() {
for k := range c {
delete(c, k)
}
}

// PathParam is a map which to store the cookies.
// PathParam is a map which to store path params.
type PathParam map[string]string

// Add method impl the method in WithStruct interface.
Expand Down Expand Up @@ -729,15 +724,15 @@ func (p PathParam) VisitAll(f func(key, val string)) {
}
}

// Reset clear the PathParams object.
// Reset clear the PathParam object.
func (p PathParam) Reset() {
for k := range p {
delete(p, k)
}
}

// FormData is a wrapper of fasthttp.Args,
// and it be used for url encode body and file body.
// and it is used for url encode body and file body.
type FormData struct {
*fasthttp.Args
}
Expand Down
2 changes: 1 addition & 1 deletion client/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *Response) Save(v any) error {
}
}

// Reset clear Response object.
// Reset clears the Response object.
func (r *Response) Reset() {
r.client = nil
r.request = nil
Expand Down