refactor(repo): refresh crate root, error and handler module
zhenyi committed
Modified lib/repo/handler/mod.rs lib/repo/handler/mod.rs +1 −0 View lib/repo/handler/mod.rs
@@ -10,6 +10,7 @@
1010pub mod git_ref;
1111pub mod graphql;
1212pub mod lifecycle;
13pub mod middleware;
1314pub mod openapi;
1415pub mod query;
1516pub mod raw;
Modified lib/repo/handler/routes.rs lib/repo/handler/routes.rs +3 −0 View lib/repo/handler/routes.rs
@@ -336,5 +336,8 @@
336336 Router::new()
337337 .merge(protected)
338338 .layer(from_fn_with_state(svc.clone(), ratelimit::<RepoService>))
339 .layer(axum::middleware::from_fn(
340 crate::handler::middleware::metrics::metrics_layer,
341 ))
339342 .with_state(svc)
340343}
Modified lib/repo/error.rs lib/repo/error.rs +17 −0 View lib/repo/error.rs
@@ -79,6 +79,23 @@
7979 | RepoError::RateLimited(_)
8080 )
8181 }
82
83 /// Bounded label for metrics. Keep stable and low-cardinality.
84 pub fn error_kind(&self) -> &'static str {
85 match self {
86 RepoError::BadRequest(_) => "bad_request",
87 RepoError::Unauthorized(_) => "unauthorized",
88 RepoError::Forbidden(_) => "forbidden",
89 RepoError::NotFound(_) => "not_found",
90 RepoError::Conflict(_) => "conflict",
91 RepoError::Unprocessable(_) => "unprocessable",
92 RepoError::RateLimited(_) => "rate_limited",
93 RepoError::Internal(_) => "internal_other",
94 RepoError::Sqlx(_) => "internal_db",
95 RepoError::Uuid(_) => "internal_uuid",
96 RepoError::Git(_) => "internal_git",
97 }
98 }
8299}
83100
84101impl IntoResponse for RepoError {
Modified lib/repo/lib.rs lib/repo/lib.rs +1 −0 View lib/repo/lib.rs
@@ -5,6 +5,7 @@
55pub mod features;
66pub mod graphql;
77pub mod handler;
8pub mod metrics;
89pub mod path;
910pub mod permission;
1011pub mod service;