diff options
author | Julio Capote <jcapote@gmail.com> | 2022-12-19 15:41:43 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2022-12-19 15:41:43 +0000 |
commit | afdf8a014236452e098ab1266c9a9315824f8103 (patch) | |
tree | 0c1db202f6f5c81783d7d2ccb1502443ab84a8ae /urls/urls.go | |
parent | 2211d7ace360548f6ee450f03d995c6bb246be2b (diff) | |
download | communique-afdf8a014236452e098ab1266c9a9315824f8103.tar.gz |
url helpers, cgi response format
Diffstat (limited to '')
-rw-r--r-- | urls/urls.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/urls/urls.go b/urls/urls.go new file mode 100644 index 0000000..5f563a7 --- /dev/null +++ b/urls/urls.go @@ -0,0 +1,34 @@ +package urls + +import ( + "fmt" + "net/url" + "path" +) + +func UrlInbox(name, domain string) (*url.URL, error) { + u, err := url.Parse(path.Join("https://", domain, "actors", name, "inbox")) + if err != nil { + return nil, fmt.Errorf("could not build inbox url: %w", err) + } + return u, nil +} + +func UrlOutbox(name, domain string) (*url.URL, error) { + u, err := url.Parse(path.Join("https://", domain, "actors", name, "outbox")) + if err != nil { + return nil, fmt.Errorf("could not build outbox url: %w", err) + } + return u, nil +} + +func UrlOutboxPage(name, domain string) (*url.URL, error) { + u, err := UrlOutbox(name, domain) + if err != nil { + return nil, fmt.Errorf("could not build outbox page url: %w", err) + } + q := u.Query() + q.Set("page", "true") + u.RawQuery = q.Encode() + return u, nil +} |