Documentation ¶
Overview ¶
Package obix 实现WebStation N4的客户端
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrSkipRedirect 禁用自动跟随重定向 ErrSkipRedirect = errors.New("skip redirect") // ErrUsernameIsEmpty 用户名不能为空 ErrUsernameIsEmpty = errors.New("username is empty") // ErrPasswordIsEmpty 密码不能为空 ErrPasswordIsEmpty = errors.New("password is empty") // ErrNoData 没有数据返回 ErrNoData = errors.New("no data received") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client obix协议的客户端, 使用uri点位请求读取或者相关设备的状态等数据
Example ¶
package main import ( "context" "encoding/xml" "log" "gitee.com/wqt/obix" ) func main() { var addr, user, pass string ctx := context.TODO() c, err := obix.NewClient(ctx, addr, user, pass) if err != nil { log.Fatalf("obix.NewClient error: %s", err) } obj, err := c.Get(ctx, "/obix") if err != nil { log.Fatalf("obix.Client.Get error: %s", err) } if obj != nil { b, err := xml.MarshalIndent(obj, "", " ") if err != nil { log.Fatalf("objx.types.MarshalIndent error: %s", err) return } log.Printf("obix.Client.Get body: %s", b) } }
Output:
func NewClient ¶
func NewClient(ctx context.Context, addr, username, password string, opts ...ClientOption) (*Client, error)
NewClient 创建一个WEBStation N4的obix客户端, addr, username和password都是必须的 opts的类型是ClientOption
func (*Client) Get ¶
Get 获取指定数据, 如果服务器返回有效数据, 返回obj非空 path不包含如"http://localhost:8000"的主机地址,
type ClientOption ¶
type ClientOption func(c *Client)
ClientOption 客户端选项函数
func WithSkipVerifyTLS ¶ added in v0.0.2
func WithSkipVerifyTLS(v bool) ClientOption
WithSkipVerifyTLS 设置跳过tls证书校验
func WithTimeout ¶ added in v0.0.2
func WithTimeout(d time.Duration) ClientOption
Click to show internal directories.
Click to hide internal directories.