Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the HTTP rate limiter configuration by scoping the governor middleware to API routes only and increasing the default rate limit values to be more permissive.
Changes:
- Refactors the Axum router so the governor rate limiter is applied only to
/api/v1/*routes. - Increases default rate limiting parameters (per-second and burst) in runtime config and the example TOML.
- Removes the previous “global” governor layer from the entire application router.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/http.rs |
Builds a dedicated API router and applies GovernorLayer only to API routes, then merges into the main router. |
src/config.rs |
Updates default rate-limit values and corresponding CLI/env defaults. |
example-config.toml |
Updates sample config to reflect the new, more permissive rate-limit defaults. |
Comments suppressed due to low confidence (1)
src/http.rs:530
- With the rate limiter now layered inside
api_router, it runs after the globalensure_configuredmiddleware. That means requests short-circuited byensure_configured(e.g. returning 503 before the cookie key is set) will no longer be rate-limited, and/api/v1/*requests also incur the outer middleware stack before being rejected with 429. If the intent is to keep the limiter effective during the unconfigured phase (and to shed load earlier), consider making the governor layer outer toensure_configuredwhile still conditionally applying it only to/api/*(e.g., via a small conditional middleware/layer that only invokes governor for API paths).
.merge(api_router)
.fallback_service(get(handle_404))
.layer(middleware::from_fn_with_state(
shared_state.clone(),
ensure_configured,
))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continued from #282