site

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSiteMap

func NewSiteMap(root URLNode, maxDepth int) siteMap

NewSiteMap takes the root url of the site and the maximum depth of the sitemap and returns a new sitemap

Types

type ErrCachedNode

type ErrCachedNode error

type ErrInvalidNode

type ErrInvalidNode error

type SiteMap

type SiteMap interface {
	// AddChild adds a valid url child node to the parent.
	// Otherwise returns an error.
	// a valid url child should:
	// - have the same Hostname as the parent
	// - have its parent path as a prefix of its own path
	// - have its depth less than max depth
	// - not have been visited already
	AddChild(parent, child URLNode) error
	// Marshal returns the json encoding of the sitemap
	Marshal() ([]byte, error)
}

type URLNode

type URLNode interface {
	// GetURL returns the URL struct of the node
	GetURL() *url.URL
	// GetHostName returns the url's hostname
	GetHostName() string
	// GetPath returns the url's path
	GetPath() string
	// GetDepth returns the url's depth
	GetDepth() int
	// Marshal returns the json encoding of url node
	Marshal() ([]byte, error)
}

func NewURLNode

func NewURLNode(u *url.URL, depth int) URLNode

NewURLNode takes a url (as URL pointer from net/url) and its depths in the sitemap and creates a new url node

Jump to

Keyboard shortcuts

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