mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Use a pointer config instead
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
|||||||
// testHTTPServer creates a test HTTP server that handles requests until
|
// testHTTPServer creates a test HTTP server that handles requests until
|
||||||
// the listener returned is closed.
|
// the listener returned is closed.
|
||||||
func testHTTPServer(
|
func testHTTPServer(
|
||||||
t *testing.T, handler http.Handler) (Config, net.Listener) {
|
t *testing.T, handler http.Handler) (*Config, net.Listener) {
|
||||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ type Config struct {
|
|||||||
|
|
||||||
// DefaultConfig returns a default configuration for the client. It is
|
// DefaultConfig returns a default configuration for the client. It is
|
||||||
// safe to modify the return value of this function.
|
// safe to modify the return value of this function.
|
||||||
func DefaultConfig() Config {
|
func DefaultConfig() *Config {
|
||||||
config := Config{
|
config := &Config{
|
||||||
Address: "https://127.0.0.1:8200",
|
Address: "https://127.0.0.1:8200",
|
||||||
HttpClient: &http.Client{},
|
HttpClient: &http.Client{},
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,11 @@ func DefaultConfig() Config {
|
|||||||
// NewClient.
|
// NewClient.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
addr *url.URL
|
addr *url.URL
|
||||||
config Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient returns a new client for the given configuration.
|
// NewClient returns a new client for the given configuration.
|
||||||
func NewClient(c Config) (*Client, error) {
|
func NewClient(c *Config) (*Client, error) {
|
||||||
u, err := url.Parse(c.Address)
|
u, err := url.Parse(c.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user