(c: &str)
| 99 | } |
| 100 | |
| 101 | fn decode_cursor(c: &str) -> Result<(DateTime<Utc>, String), AppError> { |
| 102 | let raw = base64::engine::general_purpose::URL_SAFE_NO_PAD |
| 103 | .decode(c.as_bytes()) |
| 104 | .map_err(|_| AppError::BadRequest("invalid cursor".to_string()))?; |
| 105 | let s = |
| 106 | String::from_utf8(raw).map_err(|_| AppError::BadRequest("invalid cursor".to_string()))?; |
| 107 | let (ts, id) = s |
| 108 | .split_once('|') |
| 109 | .ok_or_else(|| AppError::BadRequest("invalid cursor".to_string()))?; |
| 110 | let parsed = DateTime::parse_from_rfc3339(ts) |
| 111 | .map_err(|_| AppError::BadRequest("invalid cursor timestamp".to_string()))? |
| 112 | .with_timezone(&Utc); |
| 113 | Ok((parsed, id.to_string())) |
| 114 | } |
| 115 | |
| 116 | #[utoipa::path( |
| 117 | get, |
no outgoing calls
no test coverage detected