Skip to content

Commit

Permalink
Use asynchronous web requests
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jun 11, 2019
1 parent f67e134 commit 3734d34
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/data/component.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use futures::compat::*;
use lsp_types::{MarkupContent, MarkupKind, Uri};
use reqwest::Client;
use reqwest::r#async::Client;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;

Expand All @@ -13,12 +14,11 @@ impl ComponentDocumentation {
pub async fn lookup(name: &str) -> Option<ComponentDocumentation> {
let uri: Uri = format!("http://ctan.org/json/2.0/pkg/{}", name)
.parse()
.unwrap();
.ok()?;

let client = Client::new();
let mut response = client.get(uri).send().ok()?;
let component: Component = response.json().ok()?;

let mut response = client.get(uri).send().compat().await.ok()?;
let component: Component = response.json().compat().await.ok()?;
if component.errors.is_some() {
return None;
}
Expand Down

0 comments on commit 3734d34

Please sign in to comment.