Skip to content

Commit

Permalink
docs(readme): improve documentation for HTTP request methods
Browse files Browse the repository at this point in the history
- Improve documentation for SetBody method, detailing parameters and return value
- Improve documentation for SetCookie method, detailing parameters and return value

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Nov 3, 2024
1 parent fff0caa commit f4988ac
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions gofight.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,14 @@ func (rc *RequestConfig) SetQuery(query H) *RequestConfig {
return rc
}

// SetBody supply raw body.
// SetBody sets the body of the request if the provided body string is not empty.
// It returns the updated RequestConfig instance.
//
// Parameters:
// - body: A string representing the body content to be set.
//
// Returns:
// - *RequestConfig: The updated RequestConfig instance.
func (rc *RequestConfig) SetBody(body string) *RequestConfig {
if len(body) > 0 {
rc.Body = body
Expand All @@ -348,7 +355,15 @@ func (rc *RequestConfig) SetBody(body string) *RequestConfig {
return rc
}

// SetCookie supply cookies what you defined.
// SetCookie sets the cookies for the request configuration.
// It takes a map of cookies and assigns it to the Cookies field of the RequestConfig
// if the provided map is not empty.
//
// Parameters:
// - cookies: A map of cookies to be set.
//
// Returns:
// - A pointer to the updated RequestConfig.
func (rc *RequestConfig) SetCookie(cookies H) *RequestConfig {
if len(cookies) > 0 {
rc.Cookies = cookies
Expand Down

0 comments on commit f4988ac

Please sign in to comment.