forked from zmxv/bitmexgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
44 lines (36 loc) · 1.12 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package bitmexgo
import (
"context"
"net/http"
)
// contextKeys are used to identify the type of value in the context.
type contextKey string
var ContextAPIKey = contextKey("apikey")
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct {
Key string
Secret string
}
type Configuration struct {
BasePath string `json:"basePath,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client
}
func NewConfiguration() *Configuration {
return &Configuration{
BasePath: "https://www.bitmex.com/api/v1",
DefaultHeader: make(map[string]string),
UserAgent: "bitmexgo/1.0.0",
}
}
func NewTestnetConfiguration() *Configuration {
return &Configuration{
BasePath: "https://testnet.bitmex.com/api/v1",
DefaultHeader: make(map[string]string),
UserAgent: "bitmexgo/1.0.0",
}
}
func NewAPIKeyContext(key, secret string) context.Context {
return context.WithValue(context.TODO(), ContextAPIKey, APIKey{Key: key, Secret: secret})
}