Documentation ¶
Index ¶
- Constants
- Variables
- func DownloadFile(filepath string, uri string) error
- func IsHttpUrl(str string) error
- func IsValidUrl(uri string) bool
- func ReadFile(uri string) (io.ReadCloser, error)
- func Send(logger api.Logger, client *http.Client, u string, method string, ...) (*http.Response, error)
- type HTTPRequestOptions
Constants ¶
View Source
const (
// EmptyCompressorAlgorithm just using to beautify codes.
EmptyCompressorAlgorithm = ""
)
Variables ¶
View Source
var BodyTypeMap = map[string]string{"none": "", "text": "text/plain", "json": "application/json", "html": "text/html", "xml": "application/xml", "javascript": "application/javascript", "form": ""}
Functions ¶
func DownloadFile ¶
func IsValidUrl ¶
Types ¶
type HTTPRequestOptions ¶
HTTPRequestOptions using for customized http request.
func WithBody ¶
func WithBody(body any, bodyType string, retErrOnConvertFailed bool, compressor message.Compressor, compressAlgorithm string) HTTPRequestOptions
WithBody specifies the request body.
NOTICE: If the body type is form, this function will try to convert body as map[string]any, and if retErrOnConvertFailed is true, it returns an error on convert failure, it converts data to a raw string if set to false.
If compressor is not nil and compressAlgorithm is not empty will compress body with given message.Compressor and set request header with key 'Accept-Encoding' and value to given compressAlgorithm.
func WithHeadersMap ¶
func WithHeadersMap(headers map[string]string) HTTPRequestOptions
WithHeadersMap adds the all header k-v pairs into request.
Click to show internal directories.
Click to hide internal directories.