(
_: (),
content: Bytes,
)
| 22 | } |
| 23 | |
| 24 | async fn check_profanity( |
| 25 | _: (), |
| 26 | content: Bytes, |
| 27 | ) -> Result<impl warp::Reply, warp::Rejection> { |
| 28 | let content = String::from_utf8(content.to_vec()).expect("Invalid UTF-8"); |
| 29 | if content.contains("shitty") { |
| 30 | Ok(warp::reply::with_status( |
| 31 | warp::reply::json(&json!({ |
| 32 | "bad_words_list": [ |
| 33 | { |
| 34 | "deviations": 0, |
| 35 | "end": 16, |
| 36 | "info": 2, |
| 37 | "original": "shitty", |
| 38 | "replacedLen": 6, |
| 39 | "start": 10, |
| 40 | "word": "shitty" |
| 41 | } |
| 42 | ], |
| 43 | "bad_words_total": 1, |
| 44 | "censored_content": "this is a ****** sentence", |
| 45 | "content": "this is a shitty sentence" |
| 46 | })), |
| 47 | http::StatusCode::OK)) |
| 48 | } else { |
| 49 | Ok(warp::reply::with_status( |
| 50 | warp::reply::json(&json!({ |
| 51 | "bad_words_list": [], |
| 52 | "bad_words_total": 0, |
| 53 | "censored_content": "", |
| 54 | "content": "this is a sentence" |
| 55 | })), |
| 56 | http::StatusCode::OK, |
| 57 | )) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | fn build_routes() -> impl Filter<Extract = impl Reply> + Clone { |
| 62 | warp::post() |
nothing calls this directly
no outgoing calls
no test coverage detected