favii

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 6 Imported by: 0

README

Favii

Go Reference Build Status

A module for fetching Favicons of an URL and other Metadata.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Favii

type Favii struct {
	// contains filtered or unexported fields
}

Favii is basically a client to use the struct. It has an http.Client for doing all HTTP Requests for fetching the HTML Pages

Example

ExampleFavii shows how to get the MetaInfo from an URL and also from that MetaInfo get favicon URL from that.

f := New(true)
metainfo, err := f.GetMetaInfo("https://git.dcpri.me/modules/favii")
if err != nil {
	log.Fatal(err)
}

fmt.Println(metainfo.GetFaviconURL())
Output:

https://git.dcpri.me/assets/img/logo.svg

func New

func New(useCache bool) *Favii

New creates a new Favii struct with http.DefaultClient and empty map, also an optional cache map

func NewWithClient

func NewWithClient(client *http.Client, useCache bool) *Favii

NewWithClient creates a new Favii struct with provided http.Client and all other things similar to New()

func (*Favii) GetMetaInfo

func (f *Favii) GetMetaInfo(url string) (*MetaInfo, error)

GetMetaInfo for getting meta information, it is mainly a wrapper around unexported method getMetaInfo().

type Link struct {
	Rel  string
	Href string
}

Link is a simple struct to keep rel and href attributes of an HTML Page mostly contains the details about link tag

type Meta

type Meta struct {
	Name    string
	Content string
}

Meta is a simple struct to keep name and content attributes of an HTML Page mostly contains the details about meta tag

type MetaInfo

type MetaInfo struct {
	Metas []Meta
	Links []Link
	// contains filtered or unexported fields
}

MetaInfo with metadata details, this includes the URL used for requesting or calling GetMetaInfo() as well.

func (*MetaInfo) GetFaviconURL

func (m *MetaInfo) GetFaviconURL() string

GetFaviconURL for getting favicon URL from the MetaInfo, using link tags, or use default /favicon.ico.

Jump to

Keyboard shortcuts

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