mirror of https://github.com/mautrix/go.git
Add path type for synapse admin API
parent
2efc1af1e7
commit
f87063cb7f
28
url.go
28
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
|
||||
|
|
Loading…
Reference in New Issue