package views import ( "fmt" "git.capotej.com/capotej/communique/urls" ) type Link struct { Rel string `json:"rel"` Type string `json:"type"` Href string `json:"href"` } type WebfingerResource struct { Subject string `json:"subject"` Aliases []string `json:"aliases"` Links []Link `json:"links"` } func RenderWebfinger(name, domain, hostname string) (*WebfingerResource, error) { actorUrl, err := urls.UrlProfile(name, domain) if err != nil { return nil, err } rs := WebfingerResource{ Subject: fmt.Sprintf("acct:%s%s", name, hostname), //hostname contains @ Aliases: []string{actorUrl.String()}, Links: []Link{ { Rel: "self", Href: actorUrl.String(), Type: "application/activity+json", }, { Rel: "self", Href: actorUrl.String(), Type: "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", }, }, } return &rs, nil }