Skip to content

Commit

Permalink
♻️ refactor: refactor codebase #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Dec 14, 2024
1 parent 03a7d63 commit 1201293
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions wrap.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wrapify

import (
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -78,6 +79,22 @@ func (w *wrapper) StatusCode() int {
return w.statusCode
}

// StatusText returns a human-readable string representation of the HTTP status.
//
// This function combines the status code with its associated status text, which
// is retrieved using the `http.StatusText` function from the `net/http` package.
// The returned string follows the format "statusCode (statusText)".
//
// For example, if the status code is 200, the function will return "200 (OK)".
// If the status code is 404, it will return "404 (Not Found)".
//
// Returns:
// - A string formatted as "statusCode (statusText)", where `statusCode` is the
// numeric HTTP status code and `statusText` is the corresponding textual description.
func (w *wrapper) StatusText() string {
return fmt.Sprintf("%d (%s)", w.StatusCode(), http.StatusText(w.StatusCode()))
}

// Message retrieves the message associated with the `wrapper` instance.
//
// This function returns the `message` field of the `wrapper`, which typically
Expand Down

0 comments on commit 1201293

Please sign in to comment.