Documentation ¶
Overview ¶
Resource pacakge is for loading resources identified by a URL. Supports for different protocols such as http, https, strings, files, exist. Other modules can register additional support for protocols such as zookeeper.
Index ¶
- Constants
- Variables
- func ContextGetHttpHeader(ctx context.Context) http.Header
- func ContextPutHttpHeader(ctx context.Context, header http.Header) context.Context
- func Fetch(ctx context.Context, url string) ([]byte, error)
- func FileResource(ctx context.Context, url string) ([]byte, error)
- func HttpResource(ctx context.Context, url string) ([]byte, error)
- func Register(protocol string, source ResourceFunc)
- type NotSupported
- type ResourceFunc
Constants ¶
View Source
const ( ResourceHttp = "http" ResourceHttps = "https" ResourceString = "string" ResourceFile = "file" )
Variables ¶
View Source
var HttpHeaderContextKey httpHeaderContextKey = 1
Functions ¶
func ContextPutHttpHeader ¶
func Fetch ¶
This is the function most user will use. Using the protocol/scheme provided with the url, different implementations will be invoked. There are standard implementations in this package (see constants). Other packages using different backends can call the `Register` function to register different implementations.
func Register ¶
func Register(protocol string, source ResourceFunc)
Packages providing different backend support for this should call this in its `init()` function.
Types ¶
type NotSupported ¶
type NotSupported struct {
Protocol string
}
func (*NotSupported) Error ¶
func (this *NotSupported) Error() string
Click to show internal directories.
Click to hide internal directories.