Skip to content

Commit 08a5e6a

Browse files
fix(axum): add default no content response
1 parent efce3ab commit 08a5e6a

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/integrations/shield-axum/src/routes/action.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use axum::{
22
Form,
33
extract::{Path, Query},
4+
http::StatusCode,
45
response::{IntoResponse, Redirect, Response},
56
};
67
use serde_json::Value;
@@ -24,8 +25,9 @@ use crate::{ExtractSession, ExtractShield, RouteError};
2425
ActionPathParams
2526
),
2627
responses(
27-
(status = 302, description = "Redirect."),
28-
(status = 500, description = "Internal server error.", body = ErrorBody),
28+
(status = NO_CONTENT, description = "Success."),
29+
(status = SEE_OTHER, description = "Redirect."),
30+
(status = INTERNAL_SERVER_ERROR, description = "Internal server error.", body = ErrorBody),
2931
)
3032
)
3133
)]
@@ -54,7 +56,7 @@ pub async fn action<U: User>(
5456
.await?;
5557

5658
Ok(match response {
57-
ResponseType::Default => todo!(),
59+
ResponseType::Default => StatusCode::NO_CONTENT.into_response(),
5860
ResponseType::Redirect(to) => Redirect::to(&to).into_response(),
5961
ResponseType::RedirectToAction { action_id } => {
6062
// TODO: Use actual frontend prefix instead of hardcoded `/auth`.

packages/integrations/shield-axum/src/routes/forms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::{ExtractSession, ExtractShield, RouteError};
1818
ActionFormsPathParams
1919
),
2020
responses(
21-
(status = 200, description = "The action forms.", body = ActionForms),
22-
(status = 500, description = "Internal server error.", body = ErrorBody),
21+
(status = OK, description = "The action forms.", body = ActionForms),
22+
(status = INTERNAL_SERVER_ERROR, description = "Internal server error.", body = ErrorBody),
2323
)
2424
)
2525
)]

packages/integrations/shield-axum/src/routes/user.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ impl UserBody {
4545
description = "Get the current user account.",
4646
tags = ["auth"],
4747
responses(
48-
(status = 200, description = "The current user account.", body = UserBody),
49-
(status = 401, description = "No account signed in.", body = ErrorBody),
50-
(status = 500, description = "Internal server error.", body = ErrorBody),
48+
(status = OK, description = "The current user account.", body = UserBody),
49+
(status = UNAUTHORIZED, description = "No account signed in.", body = ErrorBody),
50+
(status = INTERNAL_SERVER_ERROR, description = "Internal server error.", body = ErrorBody),
5151
)
5252
)
5353
)]

0 commit comments

Comments
 (0)