Skip to content

refactor: add context support and improve error handling#6

Merged
RoseSecurity merged 1 commit intomainfrom
add-configurable-ctx-and-error-handling
Feb 27, 2026
Merged

refactor: add context support and improve error handling#6
RoseSecurity merged 1 commit intomainfrom
add-configurable-ctx-and-error-handling

Conversation

@RoseSecurity
Copy link
Copy Markdown
Collaborator

what

  • Add context.Context as first parameter to all API methods
  • Replace ClientOptions struct with functional options pattern
  • Add WithHTTPClient and WithAPIURL option functions
  • Introduce APIError type for structured error responses
  • Add input validation with sentinel errors for common cases
  • URL-encode path parameters to prevent injection
  • Use http.NewRequestWithContext for proper cancellation
  • Make Client fields private for better encapsulation
  • Accept 2xx status codes instead of only 200/204
  • Update tests to use new client constructor and context
  • Bump github.com/google/go-cmp to v0.7.0
  • Add gofumpt, goimports, and golangci-lint to tools

- Add context.Context as first parameter to all API methods
- Replace ClientOptions struct with functional options pattern
- Add WithHTTPClient and WithAPIURL option functions
- Introduce APIError type for structured error responses
- Add input validation with sentinel errors for common cases
- URL-encode path parameters to prevent injection
- Use http.NewRequestWithContext for proper cancellation
- Make Client fields private for better encapsulation
- Accept 2xx status codes instead of only 200/204
- Update tests to use new client constructor and context
- Bump github.com/google/go-cmp to v0.7.0
- Add gofumpt, goimports, and golangci-lint to tools
@RoseSecurity RoseSecurity merged commit c410806 into main Feb 27, 2026
4 checks passed
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.

1 participant