Skip to content

Commit

Permalink
refactor apexlogs handler to require authToken
Browse files Browse the repository at this point in the history
not sure why I made it optional :D it is not
  • Loading branch information
tj committed Jul 11, 2020
1 parent 9282528 commit 452a4d9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
4 changes: 2 additions & 2 deletions _examples/apexlogs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

func main() {
url := os.Getenv("APEX_LOGS_URL")
token := os.Getenv("APEX_LOGS_AUTH_TOKEN")
projectID := os.Getenv("APEX_LOGS_PROJECT_ID")
authToken := os.Getenv("APEX_LOGS_AUTH_TOKEN")

h := apexlogs.New(url, projectID, apexlogs.WithAuthToken(token))
h := apexlogs.New(url, projectID, authToken)

defer h.Close()

Expand Down
12 changes: 3 additions & 9 deletions handlers/apexlogs/apexlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,18 @@ type Handler struct {
// Option function.
type Option func(*Handler)

// New Apex Logs handler with the url, projectID and options.
func New(url, projectID string, options ...Option) *Handler {
// New Apex Logs handler with the url, projectID, authToken and options.
func New(url, projectID, authToken string, options ...Option) *Handler {
var v Handler
v.url = url
v.projectID = projectID
v.authToken = authToken
for _, o := range options {
o(&v)
}
return &v
}

// WithAuthToken sets the authentication token used for requests.
func WithAuthToken(token string) Option {
return func(v *Handler) {
v.authToken = token
}
}

// WithHTTPClient sets the HTTP client used for requests.
func WithHTTPClient(client *http.Client) Option {
return func(v *Handler) {
Expand Down
25 changes: 0 additions & 25 deletions handlers/apexlogs/apexlogs_test.go

This file was deleted.

0 comments on commit 452a4d9

Please sign in to comment.