Keep client config inside main file
This commit is contained in:
parent
994c114b5a
commit
5edd23278d
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,6 +19,11 @@ const (
|
|||
)
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
Host string
|
||||
Port int
|
||||
Timeout time.Duration
|
||||
}
|
||||
Client struct {
|
||||
Config *Config
|
||||
httpClient *http.Client
|
||||
|
@ -38,6 +44,12 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func (c *Config) UseDefaults() {
|
||||
c.Host = "127.0.0.1"
|
||||
c.Port = 4401
|
||||
c.Timeout = 60 * time.Second
|
||||
}
|
||||
|
||||
func NewClient(c *Config) *Client {
|
||||
return &Client{
|
||||
Config: c,
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
Host string
|
||||
Port int
|
||||
Timeout time.Duration
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Config) UseDefaults() {
|
||||
c.Host = "127.0.0.1"
|
||||
c.Port = 4401
|
||||
c.Timeout = 60 * time.Second
|
||||
}
|
Loading…
Reference in New Issue