Documentation ¶
Overview ¶
Package config provides configuration for client apps based on the Cryptowatch SDK.
Index ¶
Constants ¶
const ( DefaultAPIURL = "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 ¶
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 DefaultFilepath ¶
DefaultFilepath determines and returns default config path. It can return an error if detecting the user's home directory has failed.
func ValidateCWDefault ¶
ValidateCWDefault performs validation of the given config by checking all the fields for correctness. It does set default values for an url if one wasn't specified.
Types ¶
type CW ¶
type CW struct { APIKey string `yaml:"api_key"` SecretKey string `yaml:"secret_key"` StreamURL string `yaml:"stream_url"` TradeURL string `yaml:"trade_url"` APIURL string `yaml:"api_url"` // contains filtered or unexported fields }
CW holds the configuration.
func NewFromFilename ¶
NewFromFilename creates a new CW from a file by the given filename.
func NewFromRaw ¶
NewFromRaw creates a new CW by unmarshaling the given raw data.
func (*CW) ValidateFunc ¶
func (c *CW) ValidateFunc(vfs ...ValidateFuncCW) error
ValidateFunc validates the config by applying each of given vfs to it.
type ValidateFuncCW ¶
ValidateFuncCW takes an instance of CW and returns an error if any occured during validation process.