Documentation ¶
Index ¶
- func ChainMiddlewares(h http.Handler, ms ...Middleware) http.Handler
- func ChainMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...Middleware) http.Handler
- func ChainRouterMiddlewares(h httprouter.Handle, ms ...RouterMiddleware) httprouter.Handle
- func ChainRouterMiddlewaresWithPrefix(h httprouter.Handle, prefixes []string, ms ...RouterMiddleware) httprouter.Handle
- func Download(ctx context.Context, c *http.Client, src, dst string) (err error)
- func DownloadInWriter(ctx context.Context, c *http.Client, src string, dst io.Writer) (err error)
- func Serve(ctx context.Context, h http.Handler, addr string, fn func(a net.Addr)) (err error)
- type Downloader
- func (d *Downloader) Download(parentCtx context.Context, paths []string, fn DownloaderFunc) (err error)
- func (d *Downloader) DownloadInDirectory(ctx context.Context, dst string, paths ...string) error
- func (d *Downloader) DownloadInFile(ctx context.Context, dst string, paths ...string) (err error)
- func (d *Downloader) DownloadInWriter(ctx context.Context, w io.Writer, paths ...string) (err error)
- type DownloaderFunc
- type DownloaderOptions
- type Middleware
- type RetryFunc
- type RouterMiddleware
- type Sender
- type SenderOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainMiddlewares ¶
func ChainMiddlewares(h http.Handler, ms ...Middleware) http.Handler
ChainMiddlewares chains middlewares
func ChainMiddlewaresWithPrefix ¶
ChainMiddlewaresWithPrefix chains middlewares if one of prefixes is present
func ChainRouterMiddlewares ¶
func ChainRouterMiddlewares(h httprouter.Handle, ms ...RouterMiddleware) httprouter.Handle
ChainRouterMiddlewares chains router middlewares
func ChainRouterMiddlewaresWithPrefix ¶
func ChainRouterMiddlewaresWithPrefix(h httprouter.Handle, prefixes []string, ms ...RouterMiddleware) httprouter.Handle
ChainRouterMiddlewares chains router middlewares if one of prefixes is present
func Download ¶
Download is a cancellable function that downloads a src into a dst using a specific *http.Client
func DownloadInWriter ¶
DownloadInWriter is a cancellable function that downloads a src into a writer using a specific *http.Client
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader represents a downloader
func NewDownloader ¶
func NewDownloader(o DownloaderOptions) (d *Downloader)
NewDownloader creates a new downloader
func (*Downloader) Download ¶
func (d *Downloader) Download(parentCtx context.Context, paths []string, fn DownloaderFunc) (err error)
Download downloads in parallel a set of src paths and executes a custom callback on each downloaded buffers
func (*Downloader) DownloadInDirectory ¶
DownloadInDirectory downloads in parallel a set of src paths and saves them in a dst directory
func (*Downloader) DownloadInFile ¶
DownloadInFile downloads in parallel a set of src paths and concatenates them in order in a writer
func (*Downloader) DownloadInWriter ¶
func (d *Downloader) DownloadInWriter(ctx context.Context, w io.Writer, paths ...string) (err error)
DownloadInWriter downloads in parallel a set of src paths and concatenates them in order in a writer
type DownloaderFunc ¶
DownloaderFunc represents a downloader func It's its responsibility to close the reader
type DownloaderOptions ¶
type DownloaderOptions struct { IgnoreErrors bool NumberOfWorkers int Sender SenderOptions }
DownloaderOptions represents downloader options
type Middleware ¶
Middleware represents a middleware
func MiddlewareBasicAuth ¶
func MiddlewareBasicAuth(username, password string) Middleware
MiddlewareBasicAuth adds basic HTTP auth to a handler
func MiddlewareContentType ¶
func MiddlewareContentType(contentType string) Middleware
MiddlewareContentType adds a content type to a handler
func MiddlewareHeaders ¶
func MiddlewareHeaders(vs map[string]string) Middleware
MiddlewareHeaders adds headers to a handler
func MiddlewareTimeout ¶
func MiddlewareTimeout(timeout time.Duration) Middleware
MiddlewareTimeout adds a timeout to a handler
type RouterMiddleware ¶
type RouterMiddleware func(httprouter.Handle) httprouter.Handle
RouterMiddleware represents a router middleware
func RouterMiddlewareBasicAuth ¶
func RouterMiddlewareBasicAuth(username, password string) RouterMiddleware
RouterMiddlewareBasicAuth adds basic HTTP auth to a router handler
func RouterMiddlewareContentType ¶
func RouterMiddlewareContentType(contentType string) RouterMiddleware
RouterMiddlewareContentType adds a content type to a router handler
func RouterMiddlewareHeaders ¶
func RouterMiddlewareHeaders(vs map[string]string) RouterMiddleware
RouterMiddlewareHeaders adds headers to a router handler
func RouterMiddlewareTimeout ¶
func RouterMiddlewareTimeout(timeout time.Duration) RouterMiddleware
RouterMiddlewareTimeout adds a timeout to a router handler
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender represents an object capable of sending http requests
func (*Sender) ExecWithRetry ¶
func (s *Sender) ExecWithRetry(name string, fn func() (*http.Response, error)) (resp *http.Response, err error)
ExecWithRetry handles retrying when fetching a response name is used for logging purposes only