httputils

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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