Documentation
¶
Index ¶
Constants ¶
View Source
const (
UserAgent = "go-billwerk/" + billwerk.Version
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder interface {
// WithBaseURL sets the base URL for the request.
// Should include the scheme and hostname.
//
// Example: WithBaseURL("https://api.reepay.com")
WithBaseURL(baseURL string) Builder
// WithEndpoint sets the endpoint for the request.
// The endpoint is appended to the base URL.
//
// Example: WithEndpoint("/v1/plans")
WithEndpoint(endpoint string) Builder
// WithParam sets a query parameter for the request.
// If the key already exists, it is overwritten.
//
// Example: WithParam("page", "1") // Results in ?page=1
WithParam(key, value string) Builder
// AddParam adds a query parameter for the request.
// If the key already exists, the value is appended.
//
// Example:
// AddParam("filter", "active") // Results in ?filter=active,
// AddParam("filter", "inactive") // Results in ?filter=active&filter=inactive
AddParam(key, value string) Builder
// WithHeader sets a header for the request.
// If the key already exists, it is overwritten.
WithHeader(key, value string) Builder
// WithBasicAuth sets the Authorization header to a Basic Auth value.
WithBasicAuth(username, password string) Builder
// WithContentTypeJSON sets the Content-Type header to application/json; charset=utf-8.
// Use this method for requests that send JSON payloads, which is a common standard for REST APIs.
WithContentTypeJSON() Builder
// WithBody sets the request body to the provided io.Reader.
WithBody(body io.Reader) Builder
// WithJSONBody sets the request body to the JSON encoding of v.
// The Content-Type header is set to application/json; charset=utf-8.
// Note: Any encoding errors are silently ignored. Ensure that v is JSON-serializable.
WithJSONBody(v interface{}) Builder
// GET builds an HTTP GET request.
GET() (*http.Request, error)
// POST builds an HTTP POST request.
POST() (*http.Request, error)
// PUT builds an HTTP PUT request.
PUT() (*http.Request, error)
// DELETE builds an HTTP DELETE request.
DELETE() (*http.Request, error)
// contains filtered or unexported methods
}
Builder is an HTTP request builder.
Click to show internal directories.
Click to hide internal directories.