Skip to content

feat(fallback): Add fallback image configuration and CLI support#21

Merged
nakamuraos merged 7 commits intomainfrom
feat/fallback-image
Apr 1, 2026
Merged

feat(fallback): Add fallback image configuration and CLI support#21
nakamuraos merged 7 commits intomainfrom
feat/fallback-image

Conversation

@nakamuraos
Copy link
Copy Markdown
Contributor

This pull request introduces new configuration options for specifying a fallback image to be served when upstream image fetches fail, along with a general response TTL setting. It updates the configuration loader, CLI arguments, environment variable documentation, and adds relevant tests to ensure correct behavior. The main changes are grouped below by theme.

Fallback Image Configuration:

  • Added new environment variables and configuration fields for specifying a fallback image (PP_FALLBACK_IMAGE_DATA, PP_FALLBACK_IMAGE_PATH, PP_FALLBACK_IMAGE_URL), HTTP code, and TTL, including logic to load these settings into the application state. (src/common/config/loader.rs, src/app.rs) [1] [2] [3] [4]
  • Updated .env.sample with detailed documentation and examples for the fallback image configuration.
  • Added tests to verify default and environment-based fallback image configuration.

General Response TTL:

  • Introduced a new PP_TTL environment variable and corresponding configuration field and CLI argument for setting a general response TTL, including documentation in .env.sample and CLI help. [1] [2] [3] [4]

Documentation Improvements:

  • Updated the CLI reference in README.md to direct users to comprehensive environment variable documentation, reflecting the expanded configuration options.

Code Quality and Consistency:

  • Refactored multi-line attribute macros in CLI argument definitions to single-line for readability and consistency. [1] [2]

These changes collectively improve the application's robustness in handling upstream failures and provide clearer, more flexible configuration options for users.

Add 6 new CLI arguments to support fallback image configuration:
- fallback_image_data: Base64-encoded image data
- fallback_image_path: Local file path
- fallback_image_url: Upstream URL
- fallback_image_http_code: HTTP status code (0 = use original)
- fallback_image_ttl: Cache TTL in seconds (0 = use PP_TTL)
- ttl: General response TTL in seconds

All fields have env var mappings (PP_*) and appropriate defaults.
Includes apply_to_env() entries and test coverage.
Add fallback field to AppState struct and load fallback image at startup in app.rs. Update controller tests to initialize fallback field. Add test to verify fallback is None by default when no fallback sources are configured.
@nakamuraos nakamuraos merged commit 675ea05 into main Apr 1, 2026
1 check passed
@nakamuraos nakamuraos deleted the feat/fallback-image branch April 1, 2026 10:10
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