(cookies: &mut Cookies, data: T)
| 32 | pub type PostResponse = (StatusCode, HeaderMap); |
| 33 | |
| 34 | pub fn post_response<T>(cookies: &mut Cookies, data: T) -> PostResponse |
| 35 | where |
| 36 | T: Serialize, |
| 37 | { |
| 38 | let valued_message_ref = ValuedMessageRef { value: &data }; |
| 39 | |
| 40 | let mut cookie = Cookie::new( |
| 41 | FLASH_COOKIE_NAME, |
| 42 | serde_json::to_string(&valued_message_ref).unwrap(), |
| 43 | ); |
| 44 | cookie.set_path("/"); |
| 45 | cookies.add(cookie); |
| 46 | |
| 47 | let mut header = HeaderMap::new(); |
| 48 | header.insert(header::LOCATION, HeaderValue::from_static("/")); |
| 49 | |
| 50 | (StatusCode::SEE_OTHER, header) |
| 51 | } |
no test coverage detected