-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgate.go
45 lines (37 loc) · 818 Bytes
/
gate.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
45
package gate
import (
"net/http"
"net/url"
)
// Version represents gate's semantic version.
const Version = "v1.2.1"
const (
bodyTypeURLEncoded = "application/x-www-form-urlencoded"
bodyTypeJSON = "application/json; charset=utf-8"
)
type (
service struct {
config *Config
baseURL *url.URL
}
)
// newService returns a new service. If a nil Config is
// provided, DefaultConfig will be used.
func newService(config *Config) *service {
if config == nil {
c := defaultConfig
config = &c
}
if config.HTTPClient == nil {
config.HTTPClient = http.DefaultClient
}
return &service{
config: config,
}
}
// withBaseURL sets a base url value returning a service pointer
// for chaining.
func (s *service) withBaseURL(baseURL string) *service {
s.baseURL, _ = url.Parse(baseURL)
return s
}