Skip to content

Support response headers via JSON environment variable#318

Merged
aram356 merged 2 commits intomainfrom
fix/response_header_settings
Feb 17, 2026
Merged

Support response headers via JSON environment variable#318
aram356 merged 2 commits intomainfrom
fix/response_header_settings

Conversation

@aram356
Copy link
Copy Markdown
Collaborator

@aram356 aram356 commented Feb 17, 2026

Summary

  • Add custom deserializer map_from_obj_or_str to parse response_headers from a JSON string env var, preserving header name casing and hyphens
  • Add test verifying JSON env var override works correctly
  • Update TOML config comments and docs with the JSON env var syntax

Closes #319

Details

The config crate lowercases env var keys and converts separators, so TRUSTED_SERVER__RESPONSE_HEADERS__X_ROBOTS_TAG becomes x_robots_tag. This makes it impossible to set headers like X-Robots-Tag via individual env vars.

The fix adds a custom serde deserializer (following the existing vec_from_seq_or_map pattern) that accepts a JSON object string:

TRUSTED_SERVER__RESPONSE_HEADERS='{"X-Robots-Tag": "noindex", "X-Custom-Header": "custom value"}'

The existing TOML [response_headers] table format is unaffected.

Test plan

  • New test test_response_headers_override_with_json_env passes
  • All 352 existing tests pass (cargo test --workspace)
  • Manual verification: set the env var and confirm headers appear in responses

@aram356 aram356 changed the title Fix response header settings feat: support response headers via JSON environment variable Feb 17, 2026
@aram356 aram356 changed the title feat: support response headers via JSON environment variable Support response headers via JSON environment variable Feb 17, 2026
Copy link
Copy Markdown
Collaborator

@ChristianPavilonis ChristianPavilonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once verified.

@aram356 aram356 merged commit 775dc72 into main Feb 17, 2026
10 checks passed
@aram356 aram356 deleted the fix/response_header_settings branch February 17, 2026 23:17
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.

Support response headers via environment variable with proper casing

2 participants