different type into_response() return error silently #2038
Answered
by
davidpdrsn
freedit-dev
asked this question in
Q&A
-
Bug ReportVersion
PlatformLINUX 5.19.0-43-generic Description#[debug_handler]
async fn add_web(Form(input): Form<FormAddWeb>) -> impl IntoResponse {
if let Ok(url) = Url::parse(&input.url.unwrap_or_default()) {
add_url(url.as_str());
let target = format!("/web?url={}", url.as_str());
Redirect::to(&target).into_response()
} else {
error!("Invalid url");
let r = (StatusCode::BAD_REQUEST, "invalid url").into_response();
dbg!(&r);
r
};
}
I have checked https://docs.rs/axum/latest/axum/response/index.html#regarding-impl-intoresponse and I know But everything looks find until the |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Jun 9, 2023
Replies: 1 comment 2 replies
-
Please elaborate. I don't understand what your issue is. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah I see it. You have a
;
after the else so you're returning()
. Another reason we don't recommend returningimpl IntoResponse