Skip to content

Commit

Permalink
Merge branch 'sqlpage.link'
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Jul 12, 2024
2 parents 3298a83 + 2a15b90 commit e705a71
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use actix_web::http::{header, StatusCode};
use actix_web::{HttpResponse, HttpResponseBuilder, ResponseError};
use anyhow::{bail, format_err, Context as AnyhowContext};
use async_recursion::async_recursion;
use awc::cookie::time::Duration;
use handlebars::{BlockContext, Context, JsonValue, RenderError, Renderable};
use serde::Serialize;
use serde_json::{json, Value};
Expand Down Expand Up @@ -150,6 +151,12 @@ impl<'a, W: std::io::Write> HeaderContext<'a, W> {
});
let secure = obj.get("secure");
cookie.set_secure(secure != Some(&json!(false)) && secure != Some(&json!(0)));
if let Some(max_age_json) = obj.get("max_age") {
let seconds = max_age_json
.as_i64()
.ok_or_else(|| anyhow::anyhow!("max_age must be a number, not {max_age_json}"))?;
cookie.set_max_age(Duration::seconds(seconds));
}
let expires = obj.get("expires");
if let Some(expires) = expires {
cookie.set_expires(actix_web::cookie::Expiration::DateTime(match expires {
Expand Down

0 comments on commit e705a71

Please sign in to comment.