Skip to content

Commit

Permalink
remove superflous Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
tzilist committed Nov 28, 2018
1 parent f209db3 commit 41160d8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
pub struct App<Data> {
data: Data,
router: Router<Data>,
default_handler: Arc<BoxedEndpoint<Data>>,
default_handler: BoxedEndpoint<Data>,
}

impl<Data: Clone + Send + Sync + 'static> App<Data> {
Expand All @@ -37,9 +37,7 @@ impl<Data: Clone + Send + Sync + 'static> App<Data> {
let mut app = App {
data,
router: Router::new(),
default_handler: Arc::new(BoxedEndpoint::new(async || {
http::status::StatusCode::NOT_FOUND
})),
default_handler: BoxedEndpoint::new(async || http::status::StatusCode::NOT_FOUND),
};

// Add RootLogger as a default middleware
Expand All @@ -60,7 +58,7 @@ impl<Data: Clone + Send + Sync + 'static> App<Data> {

/// Set the default handler for the app, a fallback function when there is no match to the route requested
pub fn default_handler<T: Endpoint<Data, U>, U>(&mut self, handler: T) -> &mut Self {
self.default_handler = Arc::new(BoxedEndpoint::new(handler));
self.default_handler = BoxedEndpoint::new(handler);
self
}

Expand All @@ -75,7 +73,7 @@ impl<Data: Clone + Send + Sync + 'static> App<Data> {
Server {
data: self.data,
router: Arc::new(self.router),
default_handler: Arc::clone(&self.default_handler),
default_handler: Arc::new(self.default_handler),
}
}

Expand Down

0 comments on commit 41160d8

Please sign in to comment.