Skip to content

Commit

Permalink
add support for reading http cookies using the new sqlpage.cookie('co…
Browse files Browse the repository at this point in the history
…okie_name') function
  • Loading branch information
lovasoa committed Jun 20, 2023
1 parent 2ce4dbe commit de948fb
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 94 deletions.
141 changes: 89 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ codegen-units = 2
[dependencies]
sqlx = { version = "0.6", features = ["any", "runtime-actix-rustls", "sqlite", "postgres", "mysql", "chrono"] }
chrono = "0.4.23"
actix-web = { version = "4", features = ["rustls"] }
actix-web = { version = "4", features = ["rustls", "cookies"] }
percent-encoding = "2.2.0"
handlebars = "5.0.0-beta.0"
log = "0.4.17"
Expand Down
3 changes: 3 additions & 0 deletions src/webserver/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ fn bind_parameters<'a>(
.post_variables
.get(x)
.or_else(|| request.get_variables.get(x)),
StmtParam::Cookie(x) => request.cookies.get(x),
};
log::debug!("Binding value {:?} in statement {}", &argument, stmt);
match argument {
Expand Down Expand Up @@ -293,10 +294,12 @@ impl Display for PreparedStatement {
}
}

#[derive(Debug, PartialEq, Eq)]
enum StmtParam {
Get(String),
Post(String),
GetOrPost(String),
Cookie(String),
}

#[actix_web::test]
Expand Down
Loading

0 comments on commit de948fb

Please sign in to comment.