Skip to content

Commit

Permalink
fix(rust): add missing /api prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 11, 2024
1 parent b389784 commit 519e44c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
24 changes: 16 additions & 8 deletions rust/agama-server/src/manager/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,15 @@ fn logs_router() -> Router<ManagerState<'static>> {
.route("/list", get(list_logs))
}

#[utoipa::path(get, path = "/manager/logs/store", responses(
(status = 200, description = "Compressed Agama logs", content_type="application/octet-stream"),
(status = 500, description = "Cannot collect the logs"),
(status = 507, description = "Server is probably out of space"),
))]
#[utoipa::path(get,
path = "/logs/store",
context_path = "/api/manager",
responses(
(status = 200, description = "Compressed Agama logs", content_type="application/octet-stream"),
(status = 500, description = "Cannot collect the logs"),
(status = 507, description = "Server is probably out of space"),
)
)]
async fn download_logs() -> impl IntoResponse {
let mut headers = HeaderMap::new();
let err_response = (headers.clone(), Body::empty());
Expand Down Expand Up @@ -259,9 +263,13 @@ async fn download_logs() -> impl IntoResponse {
}
}

#[utoipa::path(get, path = "/manager/logs/list", responses(
(status = 200, description = "Lists of collected logs", body = logs::LogsLists)
))]
#[utoipa::path(get,
path = "/logs/list",
context_path = "/api/manager",
responses(
(status = 200, description = "Lists of collected logs", body = logs::LogsLists)
)
)]
pub async fn list_logs() -> Json<logs::LogsLists> {
Json(logs::list())
}
3 changes: 2 additions & 1 deletion rust/agama-server/src/network/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ async fn add_connection(

#[utoipa::path(
get,
path = "/network/connections/:id",
path = "/connections/:id",
context_path = "/api/network",
responses(
(status = 200, description = "Get connection given by its ID", body = NetworkConnection)
)
Expand Down
21 changes: 15 additions & 6 deletions rust/agama-server/src/web/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ pub struct PingResponse {
status: String,
}

#[utoipa::path(get, path = "/ping", responses(
(status = 200, description = "The API is working", body = PingResponse)
))]
#[utoipa::path(
get,
path = "/ping",
context_path = "/api",
responses(
(status = 200, description = "The API is working", body = PingResponse)
)
)]
pub async fn ping() -> Json<PingResponse> {
Json(PingResponse {
status: "success".to_string(),
Expand All @@ -61,9 +66,13 @@ pub struct LoginRequest {
pub password: String,
}

#[utoipa::path(post, path = "/api/auth", responses(
(status = 200, description = "The user has been successfully authenticated.", body = AuthResponse)
))]
#[utoipa::path(post,
path = "/auth",
context_path = "/api",
responses(
(status = 200, description = "The user has been successfully authenticated.", body = AuthResponse)
)
)]
pub async fn login(
State(state): State<ServiceState>,
Json(login): Json<LoginRequest>,
Expand Down

0 comments on commit 519e44c

Please sign in to comment.