Add helper, updaet TODO, add app.db to gitignore
This commit is contained in:
parent
f6797049af
commit
ac52322b2b
|
@ -1 +1,2 @@
|
|||
/target
|
||||
app.db
|
3
TODO
3
TODO
|
@ -6,6 +6,7 @@
|
|||
- ip blacklist
|
||||
- clear/delete hits
|
||||
- move db operations out of db_delegate
|
||||
- email notification on hit
|
||||
- ORM?
|
||||
- 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 pixel;
|
||||
mod helpers;
|
||||
|
||||
|
||||
fn main() {
|
||||
|
@ -162,7 +163,8 @@ fn create_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> R
|
|||
Ok(pixel) => pixel,
|
||||
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 {
|
||||
|
@ -186,7 +188,9 @@ fn delete_pixel(request: &Request, manager_delegate: &PixelManagerDelegate) -> R
|
|||
} else {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue