Skip to content

Commit

Permalink
🔇 silent changes: add base function #4 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Dec 14, 2024
1 parent 3408908 commit cb7c14b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wrapify

import (
"fmt"
"time"

"github.com/sivaosorg/unify4g"
Expand Down Expand Up @@ -431,6 +432,22 @@ func (w *wrapper) WithMessage(message string) *wrapper {
return w
}

// WithMessagef sets a formatted message for the `wrapper` instance.
//
// This function constructs a formatted string using the provided format string and arguments,
// assigns it to the `message` field of the `wrapper`, and returns the modified instance.
//
// Parameters:
// - message: A format string for constructing the message.
// - args: A variadic list of arguments to be interpolated into the format string.
//
// Returns:
// - A pointer to the modified `wrapper` instance, enabling method chaining.
func (w *wrapper) WithMessagef(message string, args ...interface{}) *wrapper {
w.message = fmt.Sprintf(message, args...)
return w
}

// WithBody sets the body data for the `wrapper` instance.
//
// This function updates the `data` field of the `wrapper` with the provided value
Expand Down Expand Up @@ -461,6 +478,22 @@ func (w *wrapper) WithPath(v string) *wrapper {
return w
}

// WithPathf sets a formatted request path for the `wrapper` instance.
//
// This function constructs a formatted string using the provided format string `v` and arguments `args`,
// assigns the resulting string to the `path` field of the `wrapper`, and returns the modified instance.
//
// Parameters:
// - v: A format string for constructing the request path.
// - args: A variadic list of arguments to be interpolated into the format string.
//
// Returns:
// - A pointer to the modified `wrapper` instance, enabling method chaining.
func (w *wrapper) WithPathf(v string, args ...interface{}) *wrapper {
w.path = fmt.Sprintf(v, args...)
return w
}

// WithHeader sets the header for the `wrapper` instance.
//
// This function updates the `header` field of the `wrapper` with the provided `header`
Expand Down

0 comments on commit cb7c14b

Please sign in to comment.