Skip to content

Commit de948fb

Browse files
committed
add support for reading http cookies using the new sqlpage.cookie('cookie_name') function
1 parent 2ce4dbe commit de948fb

File tree

5 files changed

+207
-94
lines changed

5 files changed

+207
-94
lines changed

Cargo.lock

Lines changed: 89 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ codegen-units = 2
1919
[dependencies]
2020
sqlx = { version = "0.6", features = ["any", "runtime-actix-rustls", "sqlite", "postgres", "mysql", "chrono"] }
2121
chrono = "0.4.23"
22-
actix-web = { version = "4", features = ["rustls"] }
22+
actix-web = { version = "4", features = ["rustls", "cookies"] }
2323
percent-encoding = "2.2.0"
2424
handlebars = "5.0.0-beta.0"
2525
log = "0.4.17"

src/webserver/database/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ fn bind_parameters<'a>(
151151
.post_variables
152152
.get(x)
153153
.or_else(|| request.get_variables.get(x)),
154+
StmtParam::Cookie(x) => request.cookies.get(x),
154155
};
155156
log::debug!("Binding value {:?} in statement {}", &argument, stmt);
156157
match argument {
@@ -293,10 +294,12 @@ impl Display for PreparedStatement {
293294
}
294295
}
295296

297+
#[derive(Debug, PartialEq, Eq)]
296298
enum StmtParam {
297299
Get(String),
298300
Post(String),
299301
GetOrPost(String),
302+
Cookie(String),
300303
}
301304

302305
#[actix_web::test]

0 commit comments

Comments
 (0)