Skip to content

Add Host and ForwardedHost request extractors for hostname extraction#20

Merged
aram356 merged 6 commits into
mainfrom
feature/host-header-with-x-forwarded
Jan 21, 2026
Merged

Add Host and ForwardedHost request extractors for hostname extraction#20
aram356 merged 6 commits into
mainfrom
feature/host-header-with-x-forwarded

Conversation

@aram356
Copy link
Copy Markdown
Contributor

@aram356 aram356 commented Jan 20, 2026

Resolves

Summary

  • Add Host extractor that extracts the hostname from the standard Host header (falls back to "localhost" if not present)
  • Add ForwardedHost extractor that prioritizes X-Forwarded-Host header over Host header for use behind reverse proxies/load balancers
  • Fix clippy warnings by simplifying error handling patterns in tests (using .err().expect() instead of match statements)
  • Add comprehensive test coverage for existing extractors (Query, Form, ValidatedQuery, ValidatedForm, ValidatedPath, Host, ForwardedHost)
  • Add Deref/DerefMut and into_inner() tests for all extractor types

Test plan

  • Unit tests added for Host extractor covering:
    • Extracts from Host header only
    • Ignores X-Forwarded-Host header
    • Defaults to "localhost" when no headers present
    • Deref and into_inner() functionality
  • Unit tests added for ForwardedHost extractor covering:
    • X-Forwarded-Host takes priority over Host header
    • Falls back to Host header when X-Forwarded-Host is absent
    • Defaults to "localhost" when no host headers present
    • Deref and into_inner() functionality
  • All existing tests pass

Copy link
Copy Markdown
Contributor

@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 pretty good 👍

@aram356 aram356 changed the title Added extractor for host header with x-forwarded-host support Add Host and ForwardedHost request extractors for hostname extraction Jan 21, 2026
@aram356 aram356 merged commit 41d650c into main Jan 21, 2026
2 checks passed
@aram356 aram356 deleted the feature/host-header-with-x-forwarded branch January 21, 2026 18:31
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.

Add Host extractor with X-Forwarded-Host support

2 participants