Documentation
¶
Index ¶
- Constants
- func DefaultHTTPSURL(host string, resource string) string
- func Get(response *Response, host string, resource string) error
- func GetRaw(response *Response, httpurl string) error
- func HTTPHandler(webFingerHandler Handler) http.Handler
- func ServeJRDBytes(responseWriter http.ResponseWriter, request *http.Request, jrd []byte)
- type ErrHTTP
- type Handler
- type HandlerFunc
- type Link
- type Response
Constants ¶
const (
ContentTypeJRD string = "application/jrd+json"
)
const DefaultPath string = "/.well-known/webfinger"
DefaultPath is the default well-known HTTP request path to WebFinger.
Not that WebFinger COULD be located at a different HTTP request path. This would be specified using /.well-known/host-meta
Variables ¶
This section is empty.
Functions ¶
func DefaultHTTPSURL ¶
DefaultHTTPSURL returns the default WebFinger URL for host and resource.
(Note this does NOT account for "/.well-known/host-meta" and "/.well-known/host-meta.js".)
func Get ¶
Get makes an HTTPS request (sending the HTTP request header "Accept: application/jrd+json") to the provided host to the default WebFinger Path with the provided resource as its query, and expects and interprets the HTTP response as JRD.
For example:
import "github.com/reiver/go-webfinger" // ... var wfResponse webfinger.Response err := webfinger.Get(&wfResponse, "example.com", "acct:reiver@mastodon.social")
See also: GetRaw
func GetRaw ¶
GetRaw makes an HTTP or HTTPS request (sending the HTTP request header "Accept: application/jrd+json") to any HTTP or HTTPS URL provided, and expects and interprets the HTTP response as JRD.
For example:
import "github.com/reiver/go-webfinger" // ... var wfResponse webfinger.Response err := webfinger.GetRaw(&wfResponse, "https://example.com/.well-known/webfinger?resource=acct:joeblow@example.com")
See also: Get
func HTTPHandler ¶
HTTPHandler returns an http.Handler based on the passed 'webFingerHandler'.
You can think of it as a way of turning a webfinger.Handler into an http.Handler.
func ServeJRDBytes ¶
func ServeJRDBytes(responseWriter http.ResponseWriter, request *http.Request, jrd []byte)
Types ¶
type ErrHTTP ¶
type ErrHTTP interface {
ErrHTTP() int
}
If webfinger.Handler's ServeWebFinger() method returns an error that is an webfinger.ErrHTTP, then webfinger.HTTPHandler() calls webfinger.ErrHTTP ErrHTTP() method for the HTTP code.
For example, if ErrHTTP() returns 404, then the HTTP error returned it 404 (Not Found).
type HandlerFunc ¶
HandlerFunc can be used to turn a func(string,...string)([]byte,error) into a Handler.
func (HandlerFunc) ServeWebFinger ¶
func (fn HandlerFunc) ServeWebFinger(resource string, rels ...string) ([]byte, error)
ServeWebFinger calls fn(rresource, rels...)
type Link ¶
type Link struct {
Rel opt.Optional[string] `json:"rel"`
Type opt.Optional[string] `json:"type"`
HRef opt.Optional[string] `json:"href"`
Titles map[string]string `json:"titles"`
Properties map[string]string `json:"properties"`
}
Link represents a JSON Resource Descriptor (JRD) 'link'.
Some examples of a JRD lin include:
{
"rel" : "http://webfinger.example/rel/profile-page",
"href" : "https://www.example.com/~dariush/"
}
And:
{
"rel": "self",
"type": "application/activity+json",
"href": "https://mastodon.social/users/reiver"
},
And:
{
"rel": "http://ostatus.org/schema/1.0/subscribe",
"template": "https://social.example/authorize_interaction?uri={uri}"
},
And:
{
"rel" : "author",
"href" : "http://blog.example.com/author/malekeh",
"titles" :
{
"en-us":"Hello world!",
"fa":"جهان درود",
},
"properties" :
{
"http://example.com/role" : "editor"
}
}
It is used with Response.