Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
View Source
var GithubPathRewriter = NewPrefixPathRewriter("github", "github.com/", "github")
Functions ¶
func RewritePath ¶
func RewritePath(pathRewriters []PathRewriterFunc, path *apiprogram.Path) (*apiprogram.Path, error)
Types ¶
type LoaderFunc ¶
func NewFSLoader ¶
func NewFSLoader(rootFS fs.FS, root string) LoaderFunc
WARNING: does not protect again relative paths. [# path-protect #] should do that.
func NewGithubLoader ¶
func NewRootFSLoader ¶ added in v0.12.3
func NewRootFSLoader() LoaderFunc
type Loaders ¶
type Loaders struct { // Only first that does not return nil is taken into account. // These apply only to paths without schemes. Versions are unaffected. PathRewriters []PathRewriterFunc // scheme -> loader CommonLoaders map[string]LoaderFunc L L.Nullable }
func (*Loaders) Fetch ¶
func (p *Loaders) Fetch( ctx context.Context, pid apiproject.ProjectID, path *apiprogram.Path, ) ([]byte, string, error)
func (*Loaders) RewritePath ¶
func (p *Loaders) RewritePath(path *apiprogram.Path) (*apiprogram.Path, error)
func (*Loaders) SetCommonLoader ¶
func (p *Loaders) SetCommonLoader(scheme string, loader LoaderFunc)
type PathRewriterFunc ¶
type PathRewriterFunc func(string) (_ *apiprogram.Path, name string, _ error)
If not rewritten, must return nil.
func NewPrefixPathRewriter ¶
func NewPrefixPathRewriter(name, prefix, newScheme string) PathRewriterFunc
If in has prefix, return new path with newScheme and prefix dropped. Essentially map prefix into a scheme, and drop the prefix from the input path.
Click to show internal directories.
Click to hide internal directories.