Skip to content

Migrate from Trillium [part 2]: Axum scaffold and proxy fallback - #2197

Merged
jcjones merged 4 commits into
mainfrom
jcj/axum-migration-part2
Apr 14, 2026
Merged

Migrate from Trillium [part 2]: Axum scaffold and proxy fallback#2197
jcjones merged 4 commits into
mainfrom
jcj/axum-migration-part2

Conversation

@jcjones

@jcjones jcjones commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Establish dual-server infrastructure for incremental route migration. Trillium remains the primary listener; a proxy handler at the end of the handler chain forwards unmatched requests to a local Axum server.

  • Add axum, reqwest, and tower-http dependencies to the main crate
  • Define AxumAppState struct (Db + Arc) for the Axum side
  • Spawn an Axum server on an ephemeral loopback port in DivviupApi::new() with a TraceLayer for request-level tracing
  • Add AxumProxy handler that forwards unhalted Trillium requests to the local Axum server via reqwest (trillium-proxy is incompatible with trillium 0.2.x, so we use a custom handler like Janus did)
  • Wire the proxy into the handler chain just before ErrorHandler
  • Add /internal/test/axum_ready endpoint and integration test to verify the proxy bridge works end-to-end

jcjones added 2 commits April 13, 2026 19:32
Establish dual-server infrastructure for incremental route migration.
Trillium remains the primary listener; a proxy handler at the end of
the handler chain forwards unmatched requests to a local Axum server.

- Add axum, reqwest, and tower-http dependencies to the main crate
- Define AxumAppState struct (Db + Arc<Config>) for the Axum side
- Spawn an Axum server on an ephemeral loopback port in DivviupApi::new()
  with a TraceLayer for request-level tracing
- Add AxumProxy handler that forwards unhalted Trillium requests to
  the local Axum server via reqwest (trillium-proxy is incompatible
  with trillium 0.2.x, so we use a custom handler like Janus did)
- Wire the proxy into the handler chain just before ErrorHandler
- Add /internal/test/axum_ready endpoint and integration test to
  verify the proxy bridge works end-to-end
Comment thread src/handler/proxy.rs
let url = if querystring.is_empty() {
format!("{}{}", self.upstream, path)
} else {
format!("{}{}?{}", self.upstream, path, querystring)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

query strings are used for pagination, so plumbed it through

@jcjones
jcjones marked this pull request as ready for review April 14, 2026 02:51
@jcjones
jcjones requested a review from a team as a code owner April 14, 2026 02:51
Comment thread src/handler.rs Outdated
&self.config.crypter
}

#[allow(dead_code)] // Scaffolded for later migration parts.

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.

We could try this, so the compiler will check that we clean this up in the future.

Suggested change
#[allow(dead_code)] // Scaffolded for later migration parts.
#[expect(dead_code)] // Scaffolded for later migration parts.

Comment thread src/handler.rs Outdated
handler: Box<dyn Handler>,
db: Db,
config: Arc<Config>,
#[handler(skip)]

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 looks like this attribute doesn't do anything. See https://docs.rs/trillium-macros/latest/src/trillium_macros/handler.rs.html#92-122

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That seems like it should have raised a complication error. Huh.

@jcjones
jcjones enabled auto-merge (squash) April 14, 2026 16:31
@jcjones
jcjones merged commit b98d207 into main Apr 14, 2026
7 of 8 checks passed
@jcjones
jcjones deleted the jcj/axum-migration-part2 branch April 14, 2026 16:32
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