Documentation ¶
Overview ¶
Package webfinger provides a simple client implementation of the WebFinger protocol.
It is a work in progress, the API is not frozen. We're trying to catchup with the last draft of the protocol: http://tools.ietf.org/html/draft-ietf-appsawg-webfinger-14 and to support the http://webfist.org
Example:
package main import ( "fmt" "github.com/ant0ine/go-webfinger" "os" ) func main() { email := os.Args[1] client := webfinger.NewClient(nil) resource, err := webfinger.MakeResource(email) if err != nil { panic(err) } jrd, err := client.GetJRD(resource) if err != nil { fmt.Println(err) return } fmt.Printf("JRD: %+v", jrd) }
Index ¶
- Variables
- func Lookup(identifier string, rels []string) (*jrd.JRD, error)
- type Client
- func (self *Client) LegacyGetJRD(resource *Resource, allow_insecure bool) (*jrd.JRD, error)
- func (self *Client) LegacyGetResourceJRDTemplateURL(domain string, allow_insecure bool) (string, error)
- func (self *Client) LegacyHostJRDURLs(domain string, allow_insecure bool) []string
- func (c *Client) Lookup(identifier string, rels []string) (*jrd.JRD, error)
- func (c *Client) LookupInsecure(identifier string, rels []string) (*jrd.JRD, error)
- func (c *Client) LookupResource(resource *Resource, rels []string, allow_insecure bool) (*jrd.JRD, error)
- type Resource
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = &Client{ client: http.DefaultClient, WebFistServer: webFistDefaultServer, }
DefaultClient is the default Client and is used by Lookup.
Functions ¶
Types ¶
type Client ¶
type Client struct { // WebFistServer is the host used for issuing WebFist queries when standard // WebFinger lookup fails. If set to the empty string, queries will not fall // back to the WebFist protocol. WebFistServer string // Allow the use of HTTP endoints for lookups. The WebFinger spec requires // all lookups be performed over HTTPS, so this should only ever be enabled // for development. AllowHTTP bool // contains filtered or unexported fields }
A Client is a WebFinger client.
func NewClient ¶
NewClient returns a new WebFinger Client. If a nil http.Client is provied, http.DefaultClient will be used. New Clients will use the default WebFist host if WebFinger lookup fails.
func (*Client) LegacyGetJRD ¶
LegacyGetJRD gets the JRD data for this resource. Implement the original WebFinger API, ie: first fetch the Host metadata, find the LRDD link, fetch the resource data and convert the XRD in JRD if necessary.
func (*Client) LegacyGetResourceJRDTemplateURL ¶
func (self *Client) LegacyGetResourceJRDTemplateURL(domain string, allow_insecure bool) (string, error)
LegacyGetResourceJRDTemplateURL gets the host meta JRD data for the specified domain, and returns the LRDD resource JRD template URL. It tries all the urls returned by client.LegacyHostJRDURLs.
func (*Client) LegacyHostJRDURLs ¶
LegacyHostJRDURLs builds a series of well known host JRD URLs from the domain.
func (*Client) Lookup ¶
Lookup returns the JRD for the specified identifier. If provided, only the specified rel values will be requested, though WebFinger servers are not obligated to respect that request.
func (*Client) LookupInsecure ¶
LookupInsecure returns the JRD for the specified identifier. If provided, only the specified rel values will be requested, though WebFinger servers are not obligated to respect that request. allows http via fallback
func (*Client) LookupResource ¶
func (c *Client) LookupResource(resource *Resource, rels []string, allow_insecure bool) (*jrd.JRD, error)
LookupResource returns the JRD for the specified Resource. If provided, only the specified rel values will be requested, though WebFinger servers are not obligated to respect that request.
type Resource ¶
Resource is a resource for which a WebFinger query can be issued.
func Parse ¶
Parse parses rawurl into a WebFinger Resource. The rawurl should be an absolute URL, or an email-like identifier (e.g. "bob@example.com").
func (*Resource) AsURIString ¶
AsURIString returns the resource as an URI string (eg: acct:user@domain).
func (*Resource) JRDURL ¶
JRDURL returns the WebFinger query URL at the specified host for this resource. If host is an empty string, the default host for the resource will be used, as returned from WebFingerHost().
func (*Resource) WebFingerHost ¶
WebFingerHost returns the default host for issuing WebFinger queries for this resource. For Resource URLs with a host component, that value is used. For URLs that do not have a host component, the host is determined by other mains if possible (for example, the domain in the addr-spec of a mailto URL). If the host cannot be determined from the URL, this value will be an empty string.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
cmdline
TODO * improve JRD output * do stuff with the JRD
|
TODO * improve JRD output * do stuff with the JRD |
simple
Minimal example, used in the README
|
Minimal example, used in the README |
Package jrd provides a simple JRD parser.
|
Package jrd provides a simple JRD parser. |
Package xrd provides a simple XRD parser.
|
Package xrd provides a simple XRD parser. |