Documentation ¶
Overview ¶
Package urlpreview provides routines for fetching short snippets of information, or previews, of URLs. It implements a set of preview handlers (which handle fetching resources) and format parsers that can be used by any previewer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrBadResponse ¶
type ErrBadResponse struct {
Status int
}
func (ErrBadResponse) Error ¶
func (e ErrBadResponse) Error() string
type Preview ¶
type Preview interface {
String() string
}
Preview is an interface for different kinds of previews. The bare minimum is the ability to get a string preview.
type PreviewHandler ¶
PreviewHandler is an interface implemented by previewers. The Preview method should return a nil Preview and a nil error if it can't handle the URL.
type Previewer ¶
type Previewer struct {
Handlers []PreviewHandler
}
Previewer is a stack of PreviewHandler instances.
func (*Previewer) Preview ¶
Preview tries to fetch a preview of the URL using registered handlers. Any error returned by any handler is bubbled up. If no handler successfully fetched a preview, Preview returns nil as both return values.
func (*Previewer) With ¶
func (p *Previewer) With(handler PreviewHandler) *Previewer
With adds a new PreviewHandler to the Previewer and returns itself. This method is useful for easy Previewer initialization.