1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-01 04:51:51 +02:00

Session wide headers, basic and bearer auth

This commit is contained in:
Nikolay Kim
2019-03-28 21:48:35 -07:00
parent 3b897da8e2
commit ea4d98d669
6 changed files with 237 additions and 22 deletions

View File

@@ -8,6 +8,25 @@ use cookie::{Cookie, CookieJar};
use crate::ClientResponse;
#[cfg(test)]
thread_local! {
static RT: std::cell::RefCell<actix_rt::Runtime> = {
std::cell::RefCell::new(actix_rt::Runtime::new().unwrap())
};
}
#[cfg(test)]
pub fn run_on<F, R>(f: F) -> R
where
F: Fn() -> R,
{
RT.with(move |rt| {
rt.borrow_mut()
.block_on(futures::future::lazy(|| Ok::<_, ()>(f())))
})
.unwrap()
}
/// Test `ClientResponse` builder
pub struct TestResponse {
head: ResponseHead,