mirror of
https://github.com/matrix-org/gomatrix
synced 2025-12-19 04:38:03 +00:00
Add responses/room types. Add buildURL functions with examples
This commit is contained in:
parent
97f4e98e1d
commit
527c6568c9
4 changed files with 160 additions and 4 deletions
28
client_test.go
Normal file
28
client_test.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package gomatrix
|
||||
|
||||
import "fmt"
|
||||
|
||||
func ExampleBuildURLWithQuery() {
|
||||
cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")
|
||||
out := cli.BuildURLWithQuery([]string{"sync"}, map[string]string{
|
||||
"filter_id": "5",
|
||||
})
|
||||
fmt.Println(out)
|
||||
// Output: https://matrix.org/_matrix/client/r0/sync?access_token=abcdef123456&filter_id=5
|
||||
}
|
||||
|
||||
func ExampleBuildURL() {
|
||||
userID := "@example:matrix.org"
|
||||
cli, _ := NewClient("https://matrix.org", userID, "abcdef123456")
|
||||
out := cli.BuildURL("user", userID, "filter")
|
||||
fmt.Println(out)
|
||||
// Output: https://matrix.org/_matrix/client/r0/user/@example:matrix.org/filter?access_token=abcdef123456
|
||||
}
|
||||
|
||||
func ExampleBuildBaseURL() {
|
||||
userID := "@example:matrix.org"
|
||||
cli, _ := NewClient("https://matrix.org", userID, "abcdef123456")
|
||||
out := cli.BuildBaseURL("_matrix", "client", "r0", "directory", "room", "#matrix:matrix.org")
|
||||
fmt.Println(out)
|
||||
// Output: https://matrix.org/_matrix/client/r0/directory/room/%23matrix:matrix.org?access_token=abcdef123456
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue