Skip to content

Commit

Permalink
Use reqwest::blocking::get in cli host
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfeldman committed Apr 6, 2021
1 parent 2d0f848 commit e052938
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/cli/platform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ pub fn roc_fx_putLine(line: RocStr) -> () {

#[no_mangle]
pub fn roc_fx_httpGetUtf8(url: RocStr) -> RocStr {
println!("TODO: read from this URL {:?}", url);
let body = reqwest::blocking::get(unsafe { url.as_str() })
.unwrap_or_else(|err| todo!("Report this HTTP error: {:?}", err));

RocStr::from_slice("url!!!".as_bytes())
let str = body
.text()
.unwrap_or_else(|err| todo!("Report this body.text() error: {:?}", err));

RocStr::from_slice(str.as_bytes())
}

#[no_mangle]
Expand Down

0 comments on commit e052938

Please sign in to comment.