mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Provide .well-known/host-meta endpoint (#1604)
* [feature] Provide .well-known/host-meta endpoint This adds the host-meta endpoint as Mastodon clients use this to discover the API domain to use when the host and account domains aren't the same. * Address review comments
This commit is contained in:
@ -28,6 +28,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
hostMetaXMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0"
|
||||
hostMetaRel = "lrdd"
|
||||
hostMetaType = "application/xrd+xml"
|
||||
hostMetaTemplate = ".well-known/webfinger?resource={uri}"
|
||||
nodeInfoVersion = "2.0"
|
||||
nodeInfoSoftwareName = "gotosocial"
|
||||
nodeInfoRel = "http://nodeinfo.diaspora.software/ns/schema/" + nodeInfoVersion
|
||||
@ -96,6 +100,22 @@ func (p *Processor) NodeInfoGet(ctx context.Context) (*apimodel.Nodeinfo, gtserr
|
||||
}, nil
|
||||
}
|
||||
|
||||
// HostMetaGet returns a host-meta struct in response to a host-meta request.
|
||||
func (p *Processor) HostMetaGet() *apimodel.HostMeta {
|
||||
protocol := config.GetProtocol()
|
||||
host := config.GetHost()
|
||||
return &apimodel.HostMeta{
|
||||
XMLNS: hostMetaXMLNS,
|
||||
Link: []apimodel.Link{
|
||||
{
|
||||
Rel: hostMetaRel,
|
||||
Type: hostMetaType,
|
||||
Template: fmt.Sprintf("%s://%s/%s", protocol, host, hostMetaTemplate),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// WebfingerGet handles the GET for a webfinger resource. Most commonly, it will be used for returning account lookups.
|
||||
func (p *Processor) WebfingerGet(ctx context.Context, requestedUsername string) (*apimodel.WellKnownResponse, gtserror.WithCode) {
|
||||
// Get the local account the request is referring to.
|
||||
|
Reference in New Issue
Block a user