This commit is contained in:
tsmethurst
2021-04-02 21:15:17 +02:00
parent 0b0f3d9e9a
commit 74bc0feee7
3 changed files with 41 additions and 20 deletions

View File

@ -21,30 +21,39 @@ package util
import "fmt"
type URIs struct {
HostURL string
UserURL string
HostURL string
UserURL string
StatusesURL string
UserURI string
InboxURL string
OutboxURL string
FollowersURL string
CollectionURL string
StatusesURI string
InboxURI string
OutboxURI string
FollowersURI string
CollectionURI string
}
func GenerateURIs(username string, protocol string, host string) *URIs {
hostURL := fmt.Sprintf("%s://%s", protocol, host)
userURL := fmt.Sprintf("%s/@%s", hostURL, username)
statusesURL := fmt.Sprintf("%s/statuses", userURL)
userURI := fmt.Sprintf("%s/users/%s", hostURL, username)
inboxURL := fmt.Sprintf("%s/inbox", userURI)
outboxURL := fmt.Sprintf("%s/outbox", userURI)
followersURL := fmt.Sprintf("%s/followers", userURI)
collectionURL := fmt.Sprintf("%s/collections/featured", userURI)
statusesURI := fmt.Sprintf("%s/statuses", userURI)
inboxURI := fmt.Sprintf("%s/inbox", userURI)
outboxURI := fmt.Sprintf("%s/outbox", userURI)
followersURI := fmt.Sprintf("%s/followers", userURI)
collectionURI := fmt.Sprintf("%s/collections/featured", userURI)
return &URIs{
HostURL: hostURL,
UserURL: userURL,
StatusesURL: statusesURL,
UserURI: userURI,
InboxURL: inboxURL,
OutboxURL: outboxURL,
FollowersURL: followersURL,
CollectionURL: collectionURL,
StatusesURI: statusesURI,
InboxURI: inboxURI,
OutboxURI: outboxURI,
FollowersURI: followersURI,
CollectionURI: collectionURI,
}
}