1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::Shared;
use std::sync::Arc;
use futures::Future;
use hyper::server::{Request, Response};
pub struct PluginData<S: Send + Sync>
{
pub shared: Arc<Shared<S>>,
pub request: Request,
pub response: Response,
}
pub trait Plugin<S: Send + Sync + 'static, E: 'static>: Send + Sync
{
fn before_handler(&self, request: &mut Request);
fn after_handler(&self,
future: Box<Future<Item = PluginData<S>, Error = E>>)
-> Box<Future<Item = PluginData<S>, Error = E>>;
}
impl<'a, S: Send + Sync + 'static, E: 'static, T: Send + Sync + Plugin<S,E>>
Plugin<S, E> for &'a T
{
fn before_handler(&self, request: &mut Request)
{
(*self).before_handler(request)
}
fn after_handler(&self,
future: Box<Future<Item = PluginData<S>, Error = E>>)
-> Box<Future<Item = PluginData<S>, Error = E>>
{
(*self).after_handler(future)
}
}
pub mod page_visits;
pub use self::page_visits::PageVisits;