impl Responder for Arc<R>

This commit is contained in:
zoumi 2017-09-03 23:03:11 +08:00 committed by GitHub
parent d36687c136
commit 0bf58c7a02
1 changed files with 8 additions and 0 deletions

View File

@ -1,6 +1,7 @@
use std::fs::File; use std::fs::File;
use std::io::Cursor; use std::io::Cursor;
use std::fmt; use std::fmt;
use std::sync::Arc;
use http::{Status, ContentType}; use http::{Status, ContentType};
use response::Response; use response::Response;
@ -202,6 +203,13 @@ impl<'r> Responder<'r> for String {
} }
} }
impl<'r,R: Responder<'r>> Responder<'r> for Arc<R> {
fn respond_to(self, req: &Request) -> Result<Response<'r>, Status> {
self.respond_to(req)
}
}
/// Returns a response with a sized body for the file. Always returns `Ok`. /// Returns a response with a sized body for the file. Always returns `Ok`.
impl<'r> Responder<'r> for File { impl<'r> Responder<'r> for File {
fn respond_to(self, _: &Request) -> Result<Response<'r>, Status> { fn respond_to(self, _: &Request) -> Result<Response<'r>, Status> {