pub fn last_event_id<T>(
) -> impl Filter<Extract = (Option<T>,), Error = Rejection> + Copy where
T: FromStr + Send + Sync + 'static,
Expand description
Gets the optional last event id from request. Typically this identifier represented as number or string.
let app = warp::sse::last_event_id::<u32>();
// The identifier is present
async {
assert_eq!(
warp::test::request()
.header("Last-Event-ID", "12")
.filter(&app)
.await
.unwrap(),
Some(12)
);
// The identifier is missing
assert_eq!(
warp::test::request()
.filter(&app)
.await
.unwrap(),
None
);
// The identifier is not a valid
assert!(
warp::test::request()
.header("Last-Event-ID", "abc")
.filter(&app)
.await
.is_err(),
);
};