summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/error.rs3
-rw-r--r--src/routes/login.rs8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs
index 48360de..6a32438 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -20,6 +20,9 @@ pub enum Error {
#[error("Http error: {0}")]
Http(#[from] axum::http::Error),
+ #[error("Header error: {0}")]
+ Header(#[from] axum::http::header::InvalidHeaderValue),
+
#[error("Json error: {0}")]
Json(#[from] serde_json::Error),
diff --git a/src/routes/login.rs b/src/routes/login.rs
index 2441a21..a580873 100644
--- a/src/routes/login.rs
+++ b/src/routes/login.rs
@@ -60,7 +60,7 @@ impl Login {
response
.headers_mut()
- .insert(SET_COOKIE, cookie.to_string().parse().unwrap());
+ .insert(SET_COOKIE, cookie.to_string().parse()?);
Ok(response)
}
@@ -72,7 +72,7 @@ pub struct Logout;
impl Logout {
#[tracing::instrument]
- pub async fn get(self) -> impl IntoResponse {
+ pub async fn get(self) -> Result<impl IntoResponse, Error> {
let cookie = Cookie::build(("token", ""))
.path("/")
.max_age(time::Duration::hours(-1))
@@ -84,9 +84,9 @@ impl Logout {
response
.headers_mut()
- .insert(SET_COOKIE, cookie.to_string().parse().unwrap());
+ .insert(SET_COOKIE, cookie.to_string().parse()?);
- response
+ Ok(response)
}
}