oven-exporter/api/client.go

26 lines
525 B
Go
Raw Normal View History

2021-07-21 00:15:57 +02:00
package api
import "encoding/base64"
// A Client for the API
type Client struct {
Token string `config:"token"`
URL string `config:"url"`
DefaultVHost string `config:"default_vhost"`
DefaultApp string `config:"default_app"`
2021-07-21 00:15:57 +02:00
}
// New Client from host and token
func New(url, token string) *Client {
2021-07-21 00:15:57 +02:00
c := &Client{
URL: url,
2021-07-21 00:15:57 +02:00
}
c.SetToken(token)
return c
}
// SetToken by using base64encoding
func (c *Client) SetToken(token string) {
c.Token = base64.StdEncoding.EncodeToString([]byte(token))
}