From f87063cb7fa992bcc35d5adb5fe41ae4b7037ea3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 19 May 2023 17:49:38 +0300 Subject: [PATCH] Add path type for synapse admin API --- url.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/url.go b/url.go index 5ea03f1..4646b44 100644 --- a/url.go +++ b/url.go @@ -31,7 +31,7 @@ func ParseAndNormalizeBaseURL(homeserverURL string) (*url.URL, error) { } // BuildURL builds a URL with the given path parts -func BuildURL(baseURL *url.URL, path ...interface{}) *url.URL { +func BuildURL(baseURL *url.URL, path ...any) *url.URL { createdURL := *baseURL rawParts := make([]string, len(path)+1) rawParts[0] = strings.TrimSuffix(createdURL.RawPath, "/") @@ -62,30 +62,36 @@ func (cli *Client) BuildURL(urlPath PrefixableURLPath) string { // BuildClientURL builds a URL with the Client's homeserver and appservice user ID set already. // This method also automatically prepends the client API prefix (/_matrix/client). -func (cli *Client) BuildClientURL(urlPath ...interface{}) string { +func (cli *Client) BuildClientURL(urlPath ...any) string { return cli.BuildURLWithQuery(ClientURLPath(urlPath), nil) } type PrefixableURLPath interface { - FullPath() []interface{} + FullPath() []any } -type BaseURLPath []interface{} +type BaseURLPath []any -func (bup BaseURLPath) FullPath() []interface{} { +func (bup BaseURLPath) FullPath() []any { return bup } -type ClientURLPath []interface{} +type ClientURLPath []any -func (cup ClientURLPath) FullPath() []interface{} { - return append([]interface{}{"_matrix", "client"}, []interface{}(cup)...) +func (cup ClientURLPath) FullPath() []any { + return append([]any{"_matrix", "client"}, []any(cup)...) } -type MediaURLPath []interface{} +type MediaURLPath []any -func (mup MediaURLPath) FullPath() []interface{} { - return append([]interface{}{"_matrix", "media"}, []interface{}(mup)...) +func (mup MediaURLPath) FullPath() []any { + return append([]any{"_matrix", "media"}, []any(mup)...) +} + +type SynapseAdminURLPath []any + +func (saup SynapseAdminURLPath) FullPath() []any { + return append([]any{"_synapse", "admin"}, []any(saup)...) } // BuildURLWithQuery builds a URL with query parameters in addition to the Client's homeserver