source

package
v0.1.771 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package source chooses where magpie reads from, with a mirror as a fallback when the official address can't be reached. The official source stays first; a mirror is only asked when it fails. The Plugins page's 「国内镜像」 switch (China) puts a mirror in China first for the few addresses one serves byte for byte.

Index

Constants

View Source
const NPMMirror = npmMirror

NPMMirror is npm's registry in China, npmmirror.

Variables

View Source
var China = func() bool { return settings.Load().ChinaMirror }

China is whether the Plugins page's 「国内镜像」 switch is on (settings.ChinaMirror); a var for tests.

Functions

func Do

func Do(c *http.Client, req *http.Request) (*http.Response, error)

Do sends req as usual and, when the official answer fails in a way a mirror could answer, tries its mirrors in order. A request that carries credentials is never sent to a mirror.

func DoFaithful added in v0.1.721

func DoFaithful(c *http.Client, req *http.Request) (*http.Response, error)

DoFaithful sends req to its official address, after its mirror in China when the 「国内镜像」 switch is on, but never to a fallback mirror: for a file nothing checks, which only a copy of the very file may stand in for.

func DoOfficial

func DoOfficial(c *http.Client, req *http.Request) (*http.Response, error)

DoOfficial sends req to its official address alone. It is for a file whose checksum must come from the same trusted place as the file itself.

func Enabled

func Enabled() bool

Enabled reports whether mirror fallback was turned on with MAGPIE_MIRRORS=on (or true, 1, cn).

func URLs

func URLs(raw string) []string

URLs is the official address followed by its mirrors, or just the official one when there is no mirror for it; with the 「国内镜像」 switch on, a mirror in China comes before it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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