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 10d733e commit 8bdf203
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func NewHeader() *header {
return h
}

// NewWrap creates a new instance of the `wrapper` struct.
// New creates a new instance of the `wrapper` struct.
//
// This function initializes a `wrapper` struct with its default values,
// including an empty map for the `Debug` field.
//
// Returns:
// - A pointer to a newly created `wrapper` instance with initialized fields.
func NewWrap() *wrapper {
func New() *wrapper {
w := &wrapper{
meta: NewMeta().
WithLocale("en_US"). // vi_VN, en_US
Expand Down
44 changes: 22 additions & 22 deletions wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ func (h *header) Description() string {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Ok(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusOK).
WithMessage(message).
WithBody(data)
Expand All @@ -820,7 +820,7 @@ func Ok(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Created(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusCreated).
WithMessage(message).
WithBody(data)
Expand All @@ -839,7 +839,7 @@ func Created(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func BadRequest(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusBadRequest).
WithMessage(message).
WithBody(data)
Expand All @@ -858,7 +858,7 @@ func BadRequest(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func NotFound(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusNotFound).
WithMessage(message).
WithBody(data)
Expand All @@ -877,7 +877,7 @@ func NotFound(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func NotImplemented(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusNotImplemented).
WithMessage(message).
WithBody(data)
Expand All @@ -896,7 +896,7 @@ func NotImplemented(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func TooManyRequest(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusTooManyRequests).
WithMessage(message).
WithBody(data)
Expand All @@ -915,7 +915,7 @@ func TooManyRequest(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Locked(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusLocked).
WithMessage(message).
WithBody(data)
Expand All @@ -934,7 +934,7 @@ func Locked(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func NoContent(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusNoContent).
WithMessage(message).
WithBody(data)
Expand All @@ -953,7 +953,7 @@ func NoContent(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Processing(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusProcessing).
WithMessage(message).
WithBody(data)
Expand All @@ -972,7 +972,7 @@ func Processing(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func UpgradeRequired(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusUpgradeRequired).
WithMessage(message).
WithBody(data)
Expand All @@ -992,7 +992,7 @@ func UpgradeRequired(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func ServiceUnavailable(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusServiceUnavailable).
WithMessage(message).
WithBody(data)
Expand All @@ -1012,7 +1012,7 @@ func ServiceUnavailable(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func InternalServerError(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusInternalServerError).
WithMessage(message).
WithBody(data)
Expand All @@ -1031,7 +1031,7 @@ func InternalServerError(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func GatewayTimeout(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusGatewayTimeout).
WithMessage(message).
WithBody(data)
Expand All @@ -1050,7 +1050,7 @@ func GatewayTimeout(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func MethodNotAllowed(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusMethodNotAllowed).
WithMessage(message).
WithBody(data)
Expand All @@ -1070,7 +1070,7 @@ func MethodNotAllowed(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Unauthorized(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusUnauthorized).
WithMessage(message).
WithBody(data)
Expand All @@ -1089,7 +1089,7 @@ func Unauthorized(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Forbidden(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusForbidden).
WithMessage(message).
WithBody(data)
Expand All @@ -1108,7 +1108,7 @@ func Forbidden(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func Accepted(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusAccepted).
WithMessage(message).
WithBody(data)
Expand All @@ -1127,7 +1127,7 @@ func Accepted(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func RequestTimeout(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusRequestTimeout).
WithMessage(message).
WithBody(data)
Expand All @@ -1146,7 +1146,7 @@ func RequestTimeout(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func RequestEntityTooLarge(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusRequestEntityTooLarge).
WithMessage(message).
WithBody(data)
Expand All @@ -1165,7 +1165,7 @@ func RequestEntityTooLarge(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func UnsupportedMediaType(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusUnsupportedMediaType).
WithMessage(message).
WithBody(data)
Expand All @@ -1184,7 +1184,7 @@ func UnsupportedMediaType(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func HTTPVersionNotSupported(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusHTTPVersionNotSupported).
WithMessage(message).
WithBody(data)
Expand All @@ -1203,7 +1203,7 @@ func HTTPVersionNotSupported(message string, data interface{}) *wrapper {
// Returns:
// - A pointer to a `wrapper` instance representing the response.
func PaymentRequired(message string, data interface{}) *wrapper {
w := NewWrap().
w := New().
WithStatusCode(http.StatusPaymentRequired).
WithMessage(message).
WithBody(data)
Expand Down

0 comments on commit 8bdf203

Please sign in to comment.