Add Env to cli example

This commit is contained in:
Richard Feldman 2022-07-17 16:26:18 -04:00 committed by Ayaz Hafiz
parent 21f3d4b8bc
commit 7d1376b273
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 137 additions and 21 deletions

View file

@ -377,3 +377,17 @@ pub extern "C" fn roc_fx_sendRequest(roc_request: &glue::Request) -> glue::Respo
}
}
}
#[no_mangle]
pub extern "C" fn roc_fx_httpGetUtf8(url: &RocStr) -> RocStr {
let body: String = ureq::get(url).call().unwrap().into_string().unwrap();
RocStr::from(body.as_str())
}
#[no_mangle]
pub extern "C" fn roc_fx_envVarUtf8(key: &RocStr) -> RocStr {
let val: String = dbg!(std::env::var(dbg!(key.as_str()))).unwrap();
RocStr::from(val.as_str())
}