Add helper, updaet TODO, add app.db to gitignore
This commit is contained in:
parent
991100ab61
commit
4da19a66b4
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
app.db
|
3
TODO
3
TODO
|
@ -6,6 +6,7 @@
|
||||||
- ip blacklist
|
- ip blacklist
|
||||||
- clear/delete hits
|
- clear/delete hits
|
||||||
- move db operations out of db_delegate
|
- move db operations out of db_delegate
|
||||||
|
- email notification on hit
|
||||||
- ORM?
|
- ORM?
|
||||||
- async?
|
- async?
|
||||||
- pipelining?
|
- pipelining?
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
use rouille::Response;
|
||||||
|
|
||||||
|
pub fn javascript_redirect(path: &str) -> Response {
|
||||||
|
Response::html(format!("
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Redirecting...</title>
|
||||||
|
<meta http-equiv=\"refresh\" content=\"0;URL='{path}'\">
|
||||||
|
<script>
|
||||||
|
window.location.href = \"{path}\";
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Redirecting...</h1>
|
||||||
|
</body>
|
||||||
|
</html>"))
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ use pixel::{Hit, PixelManager, PixelManagerDelegate, TrackingPixel, User};
|
||||||
|
|
||||||
mod db;
|
mod db;
|
||||||
mod pixel;
|
mod pixel;
|
||||||
|
mod helpers;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -162,7 +163,8 @@ fn create_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> R
|
||||||
Ok(pixel) => pixel,
|
Ok(pixel) => pixel,
|
||||||
Err(_) => return Response::empty_400()
|
Err(_) => return Response::empty_400()
|
||||||
};
|
};
|
||||||
Response::redirect_303("/manage")
|
// Response::redirect_303("/manage")
|
||||||
|
helpers::javascript_redirect("/manage")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> Response {
|
fn delete_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> Response {
|
||||||
|
@ -186,7 +188,9 @@ fn delete_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> R
|
||||||
} else {
|
} else {
|
||||||
return Response::empty_400(); // could not find pixel
|
return Response::empty_400(); // could not find pixel
|
||||||
}
|
}
|
||||||
Response::redirect_303("/manage")
|
// Response::redirect_303("/manage")
|
||||||
|
helpers::javascript_redirect("/manage")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_hit(pixel_id: &str, request: &Request, manager_delegate: &PixelManagerDelegate) {
|
fn register_hit(pixel_id: &str, request: &Request, manager_delegate: &PixelManagerDelegate) {
|
||||||
|
|
Loading…
Reference in New Issue