matrix

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

README

Go Reference

healthcheck

Client module for matrix.

This project is released under GNU Affero General Public License v3.0, see LICENCE file in this repo for more info.

Documentation

Overview

Package matrix allows interfacing with a matrix server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTP added in v0.0.3

func HTTP(
	ctx context.Context, homeserver, token, method, path string, request, response interface{},
) error

HTTP performs a http exchangewith a matrix server. It takes the homeserver url, the client token, the http method, the path including the query and pointers to request and response payload as arguments. Request payload may be nil. Token may be empty to send an unauthenticated request.

Types

type Client added in v0.0.3

type Client struct {
	// contains filtered or unexported fields
}

Client to interface with a matrix server.

func New

func New(ctx context.Context, homeserver, token string) (Client, error)

New creates a new matrix client. It takes the homeserver url to contact and the client token to use as an argument. It does a whoami request to get user ID and device ID of the token. Returns an error if that fails.

func (Client) Device added in v0.0.3

func (c Client) Device() string

Device ID of this client.

func (Client) HTTP added in v0.0.3

func (c Client) HTTP(ctx context.Context, method, path string, request, response interface{}) error

HTTP performs a http exchange with the matrix server. It takes the http method, the path including the query and pointers to request and response payload as arguments. Request payload may be nil.

func (Client) NextTXID added in v0.0.6

func (c Client) NextTXID() string

NextTXID returns the next unique transaction ID as string.

func (Client) User added in v0.0.3

func (c Client) User() string

User ID of this client.

type Response

type Response struct {
	ErrCode string `json:"errcode"`
	ErrMsg  string `json:"error"`
}

Response is the base for all HTTP responses returned by a matrix server.

func (Response) AsError

func (r Response) AsError() error

AsError returns a descriptive error instance if the matrix server has included an error in the response. Returns nil otherwise.

Directories

Path Synopsis
Package event defines the basic event type for interacting with matrix servers.
Package event defines the basic event type for interacting with matrix servers.
Package filter allows creating sync filters.
Package filter allows creating sync filters.
Package login allows logging in with a matrix server.
Package login allows logging in with a matrix server.
Package room handles matrix rooms.
Package room handles matrix rooms.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL