Skip to content

Commit 66ea41c

Browse files
committed
axum: Adjust to new path syntax
1 parent ebeac26 commit 66ea41c

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/config/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Server {
109109
/// - `FORCE_UNCONDITIONAL_REDIRECTS`: Whether to force unconditional redirects in the download
110110
/// endpoint even with a healthy database pool.
111111
/// - `BLOCKED_ROUTES`: A comma separated list of HTTP route patterns that are manually blocked
112-
/// by an operator (e.g. `/crates/:crate_id/:version/download`).
112+
/// by an operator (e.g. `/crates/{crate_id}/{version}/download`).
113113
///
114114
/// # Panics
115115
///

src/controllers/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use http::request::Parts;
66
use http::{header, StatusCode};
77
use prometheus::TextEncoder;
88

9-
/// Handles the `GET /api/private/metrics/:kind` endpoint.
9+
/// Handles the `GET /api/private/metrics/{kind}` endpoint.
1010
pub async fn prometheus(app: AppState, Path(kind): Path<String>, req: Parts) -> AppResult<String> {
1111
if let Some(expected_token) = &app.config.metrics_authorization_token {
1212
let provided_token = req

src/middleware/cargo_compat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ pub async fn middleware(
7575
fn is_cargo_endpoint(method: &Method, path: &str) -> bool {
7676
const CARGO_ENDPOINTS: &[(Method, &str)] = &[
7777
(Method::PUT, "/api/v1/crates/new"),
78-
(Method::DELETE, "/api/v1/crates/:crate_id/:version/yank"),
79-
(Method::PUT, "/api/v1/crates/:crate_id/:version/unyank"),
80-
(Method::GET, "/api/v1/crates/:crate_id/owners"),
81-
(Method::PUT, "/api/v1/crates/:crate_id/owners"),
82-
(Method::DELETE, "/api/v1/crates/:crate_id/owners"),
78+
(Method::DELETE, "/api/v1/crates/{crate_id}/{version}/yank"),
79+
(Method::PUT, "/api/v1/crates/{crate_id}/{version}/unyank"),
80+
(Method::GET, "/api/v1/crates/{crate_id}/owners"),
81+
(Method::PUT, "/api/v1/crates/{crate_id}/owners"),
82+
(Method::DELETE, "/api/v1/crates/{crate_id}/owners"),
8383
(Method::GET, "/api/v1/crates"),
8484
];
8585

@@ -154,7 +154,7 @@ mod tests {
154154
.route("/500", internal)
155155
.route("/api/v1/crates/new", put(|| async { StatusCode::CREATED }))
156156
.route(
157-
"/api/v1/crates/:crate_id/owners",
157+
"/api/v1/crates/{crate_id}/owners",
158158
get(|| async { StatusCode::INTERNAL_SERVER_ERROR }),
159159
)
160160
.layer(from_fn_with_state(StatusCodeConfig::AdjustAll, middleware))

src/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
9191

9292
let mut router = router
9393
// Metrics
94-
.route("/api/private/metrics/:kind", get(metrics::prometheus))
94+
.route("/api/private/metrics/{kind}", get(metrics::prometheus))
9595
// Alerts from GitHub scanning for exposed API tokens
9696
.route(
9797
"/api/github/secret-scanning/verify",

src/tests/blocked_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn test_blocked_download_route() {
3232
config.blocked_routes.clear();
3333
config
3434
.blocked_routes
35-
.insert("/api/v1/crates/:name/:version/download".into());
35+
.insert("/api/v1/crates/{name}/{version}/download".into());
3636
})
3737
.with_user()
3838
.await;

src/tests/routes/crates/owners/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use insta::assert_snapshot;
77

88
// This is testing Cargo functionality! ! !
99
// specifically functions modify_owners and add_owners
10-
// which call the `PUT /crates/:crate_id/owners` route
10+
// which call the `PUT /crates/{crate_id}/owners` route
1111
#[tokio::test(flavor = "multi_thread")]
1212
async fn test_cargo_invite_owners() {
1313
let (app, _, owner) = TestApp::init().with_user().await;

src/tests/routes/users/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn show_latest_user_case_insensitively() {
3232
// available for anyone to take. We need to support having multiple user accounts
3333
// with the same gh_login in crates.io. `gh_id` is stable across renames, so that field
3434
// should be used for uniquely identifying GitHub accounts whenever possible. For the
35-
// crates.io/user/:username pages, the best we can do is show the last crates.io account
35+
// crates.io/user/{username} pages, the best we can do is show the last crates.io account
3636
// created with that username.
3737

3838
let user1 = NewUser::new(

src/tests/user.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async fn github_with_email_does_not_overwrite_email() -> anyhow::Result<()> {
134134
}
135135

136136
/// Given a crates.io user, check that the user's email can be
137-
/// updated in the database (PUT /user/:user_id), then check
137+
/// updated in the database (PUT /user/{user_id}), then check
138138
/// that the updated email is sent back to the user (GET /me).
139139
#[tokio::test(flavor = "multi_thread")]
140140
async fn test_email_get_and_put() -> anyhow::Result<()> {
@@ -155,7 +155,7 @@ async fn test_email_get_and_put() -> anyhow::Result<()> {
155155

156156
/// Given a new user, test that their email can be added
157157
/// to the email table and a token for the email is generated
158-
/// and added to the token table. When /confirm/:email_token is
158+
/// and added to the token table. When /confirm/{email_token} is
159159
/// requested, check that the response back is ok, and that
160160
/// the email_verified field on user is now set to true.
161161
#[tokio::test(flavor = "multi_thread")]

0 commit comments

Comments
 (0)