Added some basic logging.
Fix cache invalidation (1 day for now).
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
use crate::context::Context;
|
||||
use crate::probe::Probe;
|
||||
|
||||
// http://vemringde.se/?q={}
|
||||
pub struct VemRingde;
|
||||
|
||||
impl Probe for VemRingde {
|
||||
fn uri(&self, number: &str) -> String {
|
||||
format!("http://vemringde.se/?q={}", number)
|
||||
}
|
||||
|
||||
fn search(&mut self, ctx: &mut Context, number: &str) -> Result<(), ()> {
|
||||
let body = if let Some(cache) = ctx.cache_get("vem_ringde", &number) {
|
||||
let _body = if let Some(cache) = ctx.cache_get("vem_ringde", &number) {
|
||||
String::from_utf8(cache.data).unwrap()
|
||||
} else {
|
||||
reqwest::get(&format!("http://vemringde.se/?q={}", number))
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap()
|
||||
};
|
||||
let body = reqwest::get(&self.uri(number)).unwrap().text().unwrap();
|
||||
|
||||
ctx.cache_set("vem_ringde", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
ctx.cache_set("vem_ringde", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
|
||||
body
|
||||
};
|
||||
|
||||
Err(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user