1
0
Fork 0

Keep client config inside main file

This commit is contained in:
Gregory Eremin 2014-09-16 15:58:27 +04:00
parent 994c114b5a
commit 5edd23278d
2 changed files with 12 additions and 19 deletions

View File

@ -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,

View File

@ -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
}