Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
BasicAuth generates a basic HTTP authentication string by encoding the provided username and password. The string is base64-encoded in the format "username:password".
Parameters: - username string: The username for basic authentication. - password string: The password for basic authentication.
Returns: - string: A base64-encoded string in the format "Basic <base64-encoded-credentials>".
func Call ¶
Call makes an HTTP request using the provided request object and decodes the response into the specified structure. It automatically sets the request Content-Type to application/json and decodes the JSON response body into the provided response interface.
Parameters: - req *http.Request: The prepared HTTP request to send. - response interface{}: The target structure to hold the decoded JSON response.
Returns: - *http.Response: The raw HTTP response object. - error: An error if the HTTP request or JSON decoding fails.
func ToJsonReq ¶
ToJsonReq converts a Go object to a JSON-encoded HTTP request payload. It serializes the provided payload to JSON format and wraps it in a buffer for sending in HTTP requests.
Parameters: - payload interface{}: The data structure to be serialized into JSON.
Returns: - *bytes.Buffer: The JSON-encoded payload wrapped in a bytes buffer, ready to be sent in a request. - error: An error if the JSON marshalling process fails.
Types ¶
This section is empty.