webmention

package module
v0.0.0-...-4a23794 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: BSD-3-Clause Imports: 9 Imported by: 8

README

webmention

GoDoc Test Status Test Coverage

webmention is a go library and command line tool for assisting in sending webmentions.

Install the library by running:

go get willnorris.com/go/webmention

To install the command line tool, run:

go install willnorris.com/go/webmention/cmd/webmention@latest

Documentation

Overview

Package webmention provides functions for discovering the webmention endpoint for URLs, and sending webmentions according to http://webmention.org/.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEndpointFound = fmt.Errorf("no endpoint found")

ErrNoEndpointFound is returned when no endpoint can be found for a certain target URL.

Functions

func DiscoverLinksFromReader

func DiscoverLinksFromReader(r io.Reader, baseURL string, sel string) ([]string, error)

DiscoverLinksFromReader discovers URLs in the HTML read from 'r'. Relative URLs found the HTML are resolved against 'baseURL'. These are candidates for sending webmentions to. If non-empty, sel is a CSS selector identifying the root node(s) to search in for links.

Types

type Client

type Client struct {
	*http.Client
}

Client is a webmention client that can discover webmention endpoints and send webmentions.

func New

func New(client *http.Client) *Client

New constructs a new webmention Client using the provided http.Client. If a nil http.Client is provided, http.DefaultClient is used.

func (*Client) DiscoverEndpoint

func (c *Client) DiscoverEndpoint(urlStr string) (string, error)

DiscoverEndpoint discovers the webmention endpoint for the provided URL.

func (c *Client) DiscoverLinks(urlStr string, sel string) ([]string, error)

DiscoverLinks discovers URLs that the provided resource links to. These are candidates for sending webmentions to. If non-empty, sel is a CSS selector identifying the root node(s) to search in for links.

func (*Client) SendWebmention

func (c *Client) SendWebmention(endpoint, source, target string) (*http.Response, error)

SendWebmention sends a webmention to endpoint, indicating that source has mentioned target.

Directories

Path Synopsis
cmd
webmention
The webmention binary is a command line utility for sending webmentions to the URLs linked to by a given webpage.
The webmention binary is a command line utility for sending webmentions to the URLs linked to by a given webpage.
third_party
header
Package header provides functions for parsing HTTP headers.
Package header provides functions for parsing HTTP headers.

Jump to

Keyboard shortcuts

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