loader

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package loader abstracts the reading document at given url.

It allows developers to register loaders for different uri schemes.

Index

Constants

This section is empty.

Variables

View Source
var Load = func(url string) (io.ReadCloser, error) {
	loader, err := get(url)
	if err != nil {
		return nil, err
	}
	return loader.Load(url)
}

Load loads the document at given url and returns []byte, if successful.

If no Loader is registered against the URI Scheme, then it returns *SchemeNotRegisteredError

Functions

func Register

func Register(scheme string, loader Loader)

Register registers given Loader for given URI Scheme.

func UnRegister

func UnRegister(scheme string)

UnRegister unregisters the registered loader(if any) for given URI Scheme.

Types

type Loader

type Loader interface {
	Load(url string) (io.ReadCloser, error)
}

Loader is the interface that wraps the basic Load method.

Load loads the document at given url and returns []byte, if successful.

type SchemeNotRegisteredError

type SchemeNotRegisteredError string

SchemeNotRegisteredError is the error type returned by Load function. It tells that no Loader is registered for that URL Scheme.

func (SchemeNotRegisteredError) Error

func (s SchemeNotRegisteredError) Error() string

Jump to

Keyboard shortcuts

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