//!Request handlers.

use context::Context;
use response::Response;
use std::sync::Arc;

///A trait for request handlers.
pub trait Handler: Send + Sync + 'static {
    ///Handle a request from the client. Panicking within this method is
    ///discouraged, to allow the server to run smoothly.
    fn handle_request(&self, context: Context, response: Response);
}

impl<F: Fn(Context, Response) + Send + Sync + 'static> Handler for F {
    fn handle_request(&self, context: Context, response: Response) {
        self(context, response);
    }
}

impl<T: Handler> Handler for Arc<T> {
    fn handle_request(&self, context: Context, response: Response) {
        (**self).handle_request(context, response);
    }
}

impl Handler for Box<Handler> {
    fn handle_request(&self, context: Context, response: Response) {
        (**self).handle_request(context, response);
    }
}

//!Request handlers.

use context::Context;
use response::Response;

///A trait for request handlers.
pub trait Handler: Send + Sync + 'static {
    ///Handle a request from the client. Panicking within this method is
    ///discouraged, to allow the server to run smoothly.
    fn handle_request(&self, context: Context, response: Response);
}

impl<F: Fn(Context, Response) + Send + Sync + 'static> Handler for F {
    fn handle_request(&self, context: Context, response: Response) {
        self(context, response);
    }
}
--- 
+++ 
@@ -2,7 +2,6 @@
 
 use context::Context;
 use response::Response;
-use std::sync::Arc;
 
 ///A trait for request handlers.
 pub trait Handler: Send + Sync + 'static {
@@ -16,15 +15,3 @@
         self(context, response);
     }
 }
-
-impl<T: Handler> Handler for Arc<T> {
-    fn handle_request(&self, context: Context, response: Response) {
-        (**self).handle_request(context, response);
-    }
-}
-
-impl Handler for Box<Handler> {
-    fn handle_request(&self, context: Context, response: Response) {
-        (**self).handle_request(context, response);
-    }
-}
Implement Handler for Arc and Box

1. Handler trait impl for Arc<T> calles handle_request() on T.
2. Handler trai can not be implemented generecally for Box without
conflicting with trait impl for Fn(). So implemented for Box<Handler>.
Clients need to cast their Box<T> as Box<Handler> to use this.

Fixes #70
