Skip to content

feat(http): unify extractor and predicate APIs for 0.3#202

Merged
singulared merged 9 commits intonextfrom
predicate-api
Feb 25, 2026
Merged

feat(http): unify extractor and predicate APIs for 0.3#202
singulared merged 9 commits intonextfrom
predicate-api

Conversation

@singulared
Copy link
Copy Markdown
Member

@singulared singulared commented Feb 3, 2026

Introduce Config-based API for extractors and Into shorthands for predicates, making the API more ergonomic and consistent. closes #88

Extractors:

  • Add extractor() entry point function
  • Add Config types: MethodConfig, PathConfig, VersionConfig, HeaderConfig, QueryConfig, BodyConfig
  • Rename PathConfig::new() to PathConfig::pattern()
  • Re-export extension traits from extractors module

Predicates:

  • Add Into implementations for direct value usage
  • Allow .method(Method::GET) instead of .method(method::Operation::eq(...))
  • Allow .status(StatusCode::OK) instead of .status(status::Operation::eq(...))

Breaking changes documented in hitbox-http/MIGRATION.md

Introduce Config-based API for extractors and Into<Operation> shorthands
for predicates, making the API more ergonomic and consistent.

Extractors:
- Add `extractor()` entry point function
- Add Config types: MethodConfig, PathConfig, VersionConfig,
  HeaderConfig, QueryConfig, BodyConfig
- Rename PathConfig::new() to PathConfig::pattern()
- Re-export extension traits from extractors module

Predicates:
- Add Into<Operation> implementations for direct value usage
- Allow `.method(Method::GET)` instead of `.method(method::Operation::eq(...))`
- Allow `.status(StatusCode::OK)` instead of `.status(status::Operation::eq(...))`

Breaking changes documented in hitbox-http/MIGRATION.md
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 93.71257% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.86%. Comparing base (b7725fc) to head (fa46354).
⚠️ Report is 10 commits behind head on next.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
hitbox-http/src/extractors/body.rs 92.39% 7 Missing ⚠️
hitbox-http/src/extractors/transform.rs 20.00% 4 Missing ⚠️
hitbox-http/src/extractors/path.rs 80.00% 3 Missing ⚠️
hitbox-http/src/predicates/request/method.rs 72.72% 3 Missing ⚠️
hitbox-http/src/predicates/version/operation.rs 66.66% 3 Missing ⚠️
hitbox-configuration/src/extractors/transform.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #202      +/-   ##
==========================================
+ Coverage   81.18%   82.86%   +1.68%     
==========================================
  Files         130      132       +2     
  Lines        8451     8604     +153     
==========================================
+ Hits         6861     7130     +269     
+ Misses       1590     1474     -116     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@singulared singulared added this to the 0.3.0 milestone Feb 6, 2026
@singulared singulared added configuration-api configuration api related issues predicates Predicates related issues labels Feb 6, 2026
Copy link
Copy Markdown
Contributor

@AndreyErmilov AndreyErmilov left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread examples/examples/axum.rs Outdated
Comment thread examples/examples/observability.rs
Comment thread examples/examples/reqwest.rs
- Add `hitbox_http::request` and `hitbox_http::response` public facade
  modules that re-export `predicate()` and `extractor()` entry points
@singulared singulared changed the base branch from main to next February 22, 2026 15:39
Replace all standalone `::new()` constructors on predicate and extractor
types with the chain API entry points:
`request::predicate()`, `response::predicate()`, `request::extractor()`.
…th typestate

- Change Hash transform to return full 64-char SHA256 instead of truncated 16-char
- Add Truncate(usize) transform for shortening values (Hash + Truncate(16) for old behavior)
- Add TransformBuilder with typestate (BuilderEmpty → BuilderFull | BuilderPerKey)
  to enforce full vs per-key exclusivity at compile time
@singulared singulared merged commit 49bfcae into next Feb 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration-api configuration api related issues predicates Predicates related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core builder API for predicates, extractors, and policies

2 participants