Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Initialization with function #11

Closed
wants to merge 1 commit into from
Closed

Conversation

jpatel531
Copy link
Contributor

New (and probably better way) of initializing the client

client := pusher.New("your_app_id", "your_app_key", "your_app_secret")

or with config options

client := pusher.NewWithConfig("your_app_id", "your_app_key", "your_app_secret", &pusher.Config{Secure: false, Host: "bla.bla.io"}

Allows validation of credentials etc. upon initialization (rather than the current struct initialization).

Might require a major release :/

WDYT @zimbatm

@jpatel531 jpatel531 mentioned this pull request Oct 7, 2015
@zimbatm
Copy link
Contributor

zimbatm commented Oct 7, 2015

@jpatel531 sorry for the late reply.

I think I would force the constructor to check for the app_id, secret and key by making the values private in the struct. But then allow all the other properties directly on the struct.

type Client struct {
  appId string
  key string
  secret string
  Config *Config
  HttpClient *net.HttpClient
}

func New(appId, key, secret string) (*Client, error) {
  // check bla bla bla
  return Client{appId, key, secret, nil, nil}
}

and then the client can use the lib like:

import "github.com/pusher/pusher-http-go/client"
cli, err := client.New("app_id", "secret", "key")
cli.HttpClient = http.Client{...}
cli.ProxyWhatever = "..."
cli.Timeout = 2 * time.Second

@kn100
Copy link
Contributor

kn100 commented May 31, 2019

closing due to age and divergence of this branch from the lib.

@kn100 kn100 closed this May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants