SHARE
TWEET

Untitled

a guest Jan 15th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async fn keyword_extraction(data: web::Data<ParserContainer>, script: web::Json<InputData>) -> HttpResponse {
  2.     let client = Client::new();//actix web client
  3.     let parser = data.parser.lock().unwrap();
  4.  
  5.     let result = script.results.map(|phrase| {
  6.         let text = phrase.text;
  7.         let lemmatizer_result = client
  8.             .post("http://some_service/")
  9.             .send_body(serde_json::to_string(text).unwrap()).await;
  10.  
  11.         let parser_input = match lemmatizer_result {
  12.             Ok(mut response) => {
  13.                 response.json::<LemmatizerResponse>().await.unwrap().result
  14.             }
  15.             Err(e) => {
  16.                 eprintln!("Error: {:#?}", e);
  17.                
  18.             }
  19.         };
  20.     });
  21.  
  22.     HttpResponse::Ok(result)
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top