You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add basic authentication support via reusable HTTP middleware
Library changes:
- Created BasicAuthHandler as a DelegatingHandler for HttpClient pipeline
- Created PassThroughHandler for when no auth is configured
- Modified AddGotenbergSharpClient to use AddHttpMessageHandler
- Handler reads credentials from GotenbergSharpClientOptions
- Properly integrates with HttpClient factory and handler pipeline
Example updates:
- All examples now load configuration from appsettings.json
- Use GotenbergSharpClientOptions instead of magic strings
- Non-DI examples manually create BasicAuthHandler from options
- DI example automatically uses BasicAuthHandler via middleware
- Added BasicAuthUsername and BasicAuthPassword to appsettings.json
- Updated examples/README.md to document basic auth configuration
Benefits of this approach:
- Reusable BasicAuthHandler across all HttpClient instances
- Configuration-driven (appsettings.json) instead of hardcoded values
- Properly integrates with DI and HttpClientFactory
- Auth header added automatically to all requests via middleware
- Clean separation of concerns
- Type-safe with GotenbergSharpClientOptions
- Testable and maintainable
All examples build successfully with 0 warnings and 0 errors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments