config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package config provides configuration for client apps based on the Cryptowatch SDK.

Index

Constants

View Source
const (
	DefaultRESTURL   = "https://api.cryptowat.ch"
	DefaultStreamURL = "wss://stream.cryptowat.ch"
	DefaultTradeURL  = "wss://trading.service.cryptowat.ch"

	Filepath = ".cw/credentials.yml"
)

Default URLs used if one of the URLs isn't specified.

Variables

View Source
var (
	ErrNilConfig      = Error{Type: "config", Why: "config is nil", How: "create and load config first"}
	ErrEmptyAPIKey    = Error{Type: "config", What: "api_url", Why: "is empty", How: "specify an api_key"}
	ErrEmptySecretKey = Error{Type: "config", What: "secret_key", Why: "is empty", How: "specify a secret_key"}
	ErrInvalidHTTPURL = Error{Type: "config", Why: "wrong url", How: "URL must be a valid http or https url"}
	ErrInvalidWSURL   = Error{Type: "config", Why: "wrong url", How: "URL must be a valid ws or wss url"}
	ErrInvalidScheme  = Error{Type: "config", Why: "invalid scheme", How: "scheme must be http(s) or ws(s)"}

	ErrNilArgs = Error{Type: "args", Why: "args is nil", How: "create an instance of args"}
)

Various validation errors.

Functions

func CheckURL

func CheckURL(given string, schemes ...string) error

CheckURL checks that the url has the correct scheme.

func DefaultFilepath

func DefaultFilepath() (string, error)

DefaultFilepath determines and returns default config path. It can return an error if detecting the user's home directory has failed.

Types

type CWConfig

type CWConfig struct {
	APIKey    string `yaml:"api_key"`
	SecretKey string `yaml:"secret_key"`
	RESTURL   string `yaml:"rest_url"`
	StreamURL string `yaml:"stream_url"`
	TradeURL  string `yaml:"trade_url"`
	// contains filtered or unexported fields
}

CWConfig holds the configuration.

func Get

func Get() *CWConfig

func NewFromPath

func NewFromPath(path string) (*CWConfig, error)

NewFromPath creates a new CW from a file by the given path.

func (*CWConfig) String

func (c *CWConfig) String() string

String can't be defined on a value receiver here because of the mutex.

type Error

type Error struct {
	Type string
	What string
	Why  string
	How  string
}

Error holds detials about an error occured during validation process.

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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