internal

package
v0.0.0-...-63b4fcb Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package internal provides useful, private Go helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(u *url.URL, s ...string) *bytes.Buffer

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

func SaveFile(dest string, u *url.URL, s ...string)

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

func URLMustParse(s string) *url.URL

URLMustParse parses a URL and panics if an error occurs. It's useful for assigning constants.

func URLWithPath

func URLWithPath(u *url.URL, s ...string) *url.URL

URLWithPath takes a base URL and a sequence of path components and concatenates the two together using path.Join's forward-slash separators.

func URLWithPathForBackblaze

func URLWithPathForBackblaze(u *url.URL, s ...string) *url.URL

Workaround: Backblaze incorrectly treats a "+" in the path component as a space, so we need to escape them.

Types

type ConfigEntry

type ConfigEntry struct {
	Mirror     string
	Areas      []string
	Components []string
}

Jump to

Keyboard shortcuts

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