Skip to content

feat(routerama): add HTTP routing crates#570

Open
geeknoid wants to merge 1 commit into
mainfrom
routerama
Open

feat(routerama): add HTTP routing crates#570
geeknoid wants to merge 1 commit into
mainfrom
routerama

Conversation

@geeknoid

Copy link
Copy Markdown
Member

Introduce the routerama family of crates:

  • routerama: blazingly fast HTTP routing (static + dynamic routers).
  • routerama_build: build-time router code generator.
  • routerama_macros: procedural macros for the routerama crate.

These build on the http_path_template crate for path-template parsing.

Copilot AI review requested due to automatic review settings July 14, 2026 01:59
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Introduces the new routerama family of crates to the Oxidizer workspace, providing compile-time generated HTTP routing (routes! / build-time generator) plus an optional runtime router (DynRouter) that is intended to match identically to the static backend by walking the same shared trie IR.

Changes:

  • Adds new crates: routerama (facade + runtime), routerama_build (generator + shared trie IR), and routerama_macros (proc-macro front door).
  • Adds correctness/differential tests, examples, and benchmarking/reporting infrastructure for static vs dynamic routing and comparisons vs other routers.
  • Wires the new crates into the workspace (dependencies, lockfile, top-level README/changelog links, spelling dictionary).

Reviewed changes

Copilot reviewed 47 out of 48 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
README.md Adds routerama to the workspace crate list.
crates/routerama/tests/routes_macro.rs Behavioral tests for routes! macro output.
crates/routerama/tests/generated_router.rs Drift-guard tests for the committed benchmark router fixture.
crates/routerama/tests/dynamic_parity.rs Differential tests asserting DynRouter matches static routing behavior.
crates/routerama/src/route.rs Defines core routing traits (Route, RouteMatch, Router).
crates/routerama/src/lib.rs Crate-level docs and re-exports for macros/build/dynamic APIs.
crates/routerama/src/dynamic.rs Runtime router implementation plus EitherRouter composition.
crates/routerama/src/codegen_helpers/scan.rs Shared scan/split primitives used by generated routers and runtime router.
crates/routerama/src/codegen_helpers/mod.rs Exposes codegen helper API surface for generated code.
crates/routerama/scripts/perf_report.rs Nightly -Zscript benchmark runner + PERF.md generator + router regeneration.
crates/routerama/README.md Crate README (doc2readme output).
crates/routerama/logo.png Adds crate logo asset (Git LFS pointer).
crates/routerama/favicon.ico Adds crate favicon asset (Git LFS pointer).
crates/routerama/examples/support/bookstore_router.rs Committed generated router used by build-script example.
crates/routerama/examples/routing.rs Static-routing example using routes!.
crates/routerama/examples/hybrid_routing.rs Example composing static router with dynamic overlay via EitherRouter.
crates/routerama/examples/dynamic_routing.rs Runtime-routing example using DynRouter.
crates/routerama/examples/build_script.rs Example showing build-time generation usage pattern.
crates/routerama/docs/PERF.md Committed performance report output.
crates/routerama/CHANGELOG.md Initial crate changelog content.
crates/routerama/Cargo.toml Crate manifest: features, deps, benches/examples, external-types allowlist.
crates/routerama/benches/gungraun_routers.rs Callgrind (gungraun) benchmark suite.
crates/routerama/benches/criterion_routers.rs Criterion benchmark suite.
crates/routerama/benches/common/routes_data.rs Shared benchmark route/lookup data.
crates/routerama/benches/common/harness.rs Shared benchmark harness building/comparing multiple routers.
crates/routerama/benches/common/generated_router.rs Committed generated router for benchmarks.
crates/routerama_macros/src/lib.rs routes! procedural macro implementation and parsing.
crates/routerama_macros/README.md Proc-macro crate README (doc2readme output).
crates/routerama_macros/logo.png Adds macros crate logo asset (Git LFS pointer).
crates/routerama_macros/favicon.ico Adds macros crate favicon asset (Git LFS pointer).
crates/routerama_macros/CHANGELOG.md Initial proc-macro crate changelog content.
crates/routerama_macros/Cargo.toml Proc-macro crate manifest.
crates/routerama_build/src/trie.rs Shared trie IR + precedence rules + capture planning.
crates/routerama_build/src/route_rule.rs RouteRule definition and template handling.
crates/routerama_build/src/lib.rs Build crate module structure + public re-exports (mostly doc-hidden).
crates/routerama_build/src/http_method.rs HttpMethod enum + helpers.
crates/routerama_build/src/generator.rs Generator API for producing router code (codegen feature).
crates/routerama_build/src/generator_builder.rs GeneratorBuilder configuration surface.
crates/routerama_build/README.md Build crate README (doc2readme output).
crates/routerama_build/logo.png Adds build crate logo asset (Git LFS pointer).
crates/routerama_build/favicon.ico Adds build crate favicon asset (Git LFS pointer).
crates/routerama_build/CHANGELOG.md Initial build crate changelog content.
crates/routerama_build/Cargo.toml Build crate manifest + codegen feature flag.
CHANGELOG.md Adds routerama to the workspace changelog index.
Cargo.toml Adds workspace deps for new crates and benchmark comparison crates.
Cargo.lock Locks new workspace deps and benchmark dependencies.
.spelling Adds router-related vocabulary to spellcheck dictionary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/routerama/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama/src/dynamic.rs
Comment thread crates/routerama/CHANGELOG.md Outdated
Comment thread crates/routerama_build/CHANGELOG.md Outdated
Comment thread crates/routerama_macros/CHANGELOG.md Outdated
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.8%. Comparing base (2cf0ffe) to head (1d0d1db).

❌ Your project check has failed because the head coverage (99.8%) is below the target coverage (100.0%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #570     +/-   ##
========================================
- Coverage   100.0%   99.8%   -0.2%     
========================================
  Files         360     369      +9     
  Lines       27886   29640   +1754     
========================================
+ Hits        27886   29586   +1700     
- Misses          0      54     +54     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings July 14, 2026 02:54
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated 2 comments.

Comment thread crates/routerama/tests/routes_macro.rs Outdated
Comment thread CHANGELOG.md
Copilot AI review requested due to automatic review settings July 14, 2026 03:35
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated 1 comment.

Comment thread CHANGELOG.md
Copilot AI review requested due to automatic review settings July 14, 2026 04:02
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated 3 comments.

Comment thread crates/routerama/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama_macros/README.md
Copilot AI review requested due to automatic review settings July 14, 2026 04:31
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 14, 2026 05:16
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 7 comments.

Comment thread crates/routerama/README.md
Comment thread crates/routerama/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama/src/dynamic.rs
Copilot AI review requested due to automatic review settings July 14, 2026 05:24
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 5 comments.

Comment thread crates/routerama/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama/src/route.rs
Comment thread crates/routerama/src/lib.rs
Copilot AI review requested due to automatic review settings July 14, 2026 05:35
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 3 comments.

Comment thread crates/routerama/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama_build/README.md
//! # #[cfg(feature = "macros")]
//! # fn main() {
//! routerama::routes! {
//! pub enum BookRoute {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not very fond of this syntax. It introduces a new "language" to define an enum and its variants, and its unclear (at least reading top level docs so far) whether I need to use / match the variants myself; which would be bad for discoverability.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hm ok, I now played with it and I see the merit of it being short; still the syntax is somewhat weird, esp. once you add a struct Foo; to it.

Comment thread crates/routerama/src/dynamic.rs
Comment thread crates/routerama_build/src/generator_builder.rs Outdated
@ralfbiedert

Copy link
Copy Markdown
Collaborator

What's the story how this composes with axum or similar?

//!
//! A fixed set of built-in routes plus a set registered at run time can be served
//! through one [`EitherRouter`] (requires the `dynamic` feature): declare a
//! companion `struct` in `routes!` to get a zero-sized [`Router`] for the static

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's unclear from the examples or descriptions why I would want that. What does an ApiRouter give me that Api combined with an EitherRouter won't?
I suspect it has something to do with avoiding generics and / or naming an empty Api type, but if so that feels hacky.

@ralfbiedert

Copy link
Copy Markdown
Collaborator

What's the story how this composes with axum or similar?

To clarify, I think there's a deeper discussion about scope and composability of this with an actual web server using this. In Axum a Router<T> has an app state T, which is used for type-safely registering routes and resolving their dependencies; and a router there type-safely ties URL paths to functions to be invoked.

Maybe this here is still a router, but it feels less like one I'd expect coming from other Rust libs ... more of a "route decoder" (in lack of a better word)?

@ralfbiedert

Copy link
Copy Markdown
Collaborator

My Github UI is really sluggish on this PR, inlining a few more comments:

  • route_field_name why is this public? Does anyone need this, it's not like I can use reflection with that knowledge to actually "find" the field then
  • Router::resolve (method, path) should be impl AsRef<str>? Route::resolve has that already.
  • Not a fan of the Route Debug / Display supertraits. As a rule of thumb, supertraits should be minimal and actual methods needing something should ask for these in addition.
  • Why is there a HttpMethod enum, but resolve still accept strings for their method?

Copilot AI review requested due to automatic review settings July 14, 2026 14:19
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

@geeknoid

Copy link
Copy Markdown
Member Author

@ralfbiedert

  • route_field_name why is this public? Does anyone need this, it's not like I can use reflection with that knowledge to actually "find" the field then

Fixed.

  • Router::resolve (method, path) should be impl AsRef<str>? Route::resolve has that already.

Fixed.

  • Not a fan of the Route Debug / Display supertraits. As a rule of thumb, supertraits should be minimal and actual methods needing something should ask for these in addition.

Removed.

  • Why is there a HttpMethod enum, but resolve still accept strings for their method?

The docs now explain the rationale. The API signature did change though, so it now transparently supports HttpMethod too.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 55 changed files in this pull request and generated 5 comments.

Comment thread crates/routerama/README.md
Comment thread crates/routerama_build/README.md
Comment thread crates/routerama_macros/README.md
Comment thread crates/routerama_build/src/trie.rs Outdated
Comment thread crates/routerama/examples/support/bookstore_router.rs Outdated
Introduce the routerama family of crates:

- routerama: blazingly fast HTTP routing (static + dynamic routers).
- routerama_build: build-time router code generator.
- routerama_macros: procedural macros for the routerama crate.

These build on the http_path_template crate for path-template parsing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 867c37d0-9e7a-46b0-b5a9-dc9f551ed128
Copilot AI review requested due to automatic review settings July 14, 2026 14:58
@github-actions

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
routerama new crate 0.1.0 0.1.0 ✅ ok
routerama_build new crate 0.1.0 0.1.0 ✅ ok
routerama_macros new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 55 changed files in this pull request and generated no new comments.

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.

3 participants