Skip to content

Instantly share code, notes, and snippets.

@deankarn
Created March 31, 2019 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deankarn/07a0891df857ffa9b8173ad9324cfce8 to your computer and use it in GitHub Desktop.
Save deankarn/07a0891df857ffa9b8173ad9324cfce8 to your computer and use it in GitHub Desktop.
package mylib
import "net/http"
// New create a new Instance of mylib
func New(someAlwaysRequiredValue string) (*Instance, error) {
return &Instance{
client: new(http.Client), // default no auth client
}, nil
}
type Instance struct {
client *http.Client
}
// BasicAuth sets the username and password for requests.
func (i *Instance) BasicAuth(username, password string) error {
// create an http client where the basic credentials
// are injected automatically into requests.
client,err := //...
if err != nil {
return err
}
i.client = client
return nil
}
// OAuth ...
func (i *Instance) OAuth(id, secret string) error{
// ....
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment