httputils

package
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFromURL

func DownloadFromURL(URL string) ([]byte, error)

DownloadFromURL downloads a file from an URL and returns the content as a slice of bytes

func IsValidURL

func IsValidURL(strURL string) bool

IsValidURL checks whether the given string is a valid URL or not

func TrimHTTPScheme added in v0.8.5

func TrimHTTPScheme(strURL string) string

TrimScheme takes a string of an URL and removes the leading scheme (http or https)

Types

type Downloader

type Downloader struct {
	Timeout time.Duration
}

func NewDownloader

func NewDownloader(opts ...DownloaderOption) *Downloader

NewDownloader creates a new Downloader to download files from an URL

func (Downloader) DownloadFromURL

func (d Downloader) DownloadFromURL(URL string) ([]byte, error)

DownloadFromURL downloads a file from an URL and returns the content as a slice of bytes

type DownloaderOption

type DownloaderOption func(*Downloader)

func WithTimeout

func WithTimeout(timeout time.Duration) DownloaderOption

WithTimeout sets a timeout on the underlying HTTP client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL