Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Commit b9002a8

Browse files
maxcountrymanaslamplr
authored andcommitted
allow authorization header or jwt cookies
Unfortunately due to the way `unify` works, we have to do [a little more work](seanmonstar/warp#658 (comment)) to make this work.
1 parent d2e307d commit b9002a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ async fn main() -> anyhow::Result<()> {
8787
csrf: Option<String>,
8888
}
8989

90-
let auth = warp::header::optional("authorization")
91-
.or(warp::cookie::optional("jwt"))
90+
let auth = warp::header("authorization")
91+
.or(warp::cookie("jwt"))
92+
.unify()
93+
.map(Some)
94+
.or(warp::any().map(|| None))
9295
.unify()
9396
.and(warp::query())
9497
.and_then(|jwt: Option<String>, query: Query| async {

0 commit comments

Comments
 (0)