-
I'm trying to save a value from a form in a cookie, but Rust refuses to compile, complaining:
Here's the offending code: use axum::{response::Redirect, Form};
use axum_extra::extract::cookie::{Cookie, PrivateCookieJar};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct LoginForm {
api_key: String,
}
async fn login_post(
Form(input): Form<LoginForm>,
jar: PrivateCookieJar,
) -> (PrivateCookieJar, Redirect) {
let api_key = input.api_key.trim();
let cookie = Cookie::new("my-cookie", api_key);
let updated_jar = jar.add(cookie);
(updated_jar, Redirect::to("/"))
} |
Beta Was this translation helpful? Give feedback.
Answered by
rouge8
Jul 9, 2022
Replies: 2 comments
-
I need to use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rouge8
-
😝 haha many hours, I find solutions but it just |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to use
let api_key = input.api_key.trim().to_string()
. I could have sworn I tried that earlier! 😩