Documentation ¶
Overview ¶
Package internal provides useful, private Go helper functions.
Index ¶
- func DownloadFile(u *url.URL, s ...string) *bytes.Buffer
- func HTTPError(w http.ResponseWriter, r *http.Request, code int)
- func SaveFile(dest string, u *url.URL, s ...string)
- func URLMustParse(s string) *url.URL
- func URLWithPath(u *url.URL, s ...string) *url.URL
- func URLWithPathForBackblaze(u *url.URL, s ...string) *url.URL
- type ConfigEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadFile ¶
DownloadFile downloads a URL and panics if an error occurs or if the HTTP request returns a non-200 status code. For convenience, callers may pass either a complete URL or a base URL followed by a sequence of path segments as in URLWithPath.
func HTTPError ¶
func HTTPError(w http.ResponseWriter, r *http.Request, code int)
HTTPError is for HTTP servers. It responds with the provided status code and a simple text-based error like "404 Not Found".
func SaveFile ¶
SaveFile downloads a URL to disk and panics if an error occurs or if the HTTP request returns a non-200 status code. The operation is atomic: the file is streamed to a temporary file which is then renamed into place. For convenience, callers may pass either a complete URL or a base URL followed by a sequence of path segments as in URLWithPath.
func URLMustParse ¶
URLMustParse parses a URL and panics if an error occurs. It's useful for assigning constants.
func URLWithPath ¶
URLWithPath takes a base URL and a sequence of path components and concatenates the two together using path.Join's forward-slash separators.