Skip to content

Commit

Permalink
chore(fmt): run cargo fmt to fix CI (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Young committed Feb 19, 2020
1 parent aa64e50 commit d5d9fdf
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions gotham/src/handler/assets/mod.rs
Expand Up @@ -209,35 +209,33 @@ fn create_file_response(options: FileOptions, state: State) -> Pin<Box<HandlerFu

let (path, encoding) = check_compressed_options(&options, &headers);

let response_future = File::open(path).and_then(|file| {
async move {
let meta = file.metadata().await?;
if not_modified(&meta, &headers) {
return Ok(http::Response::builder()
.status(StatusCode::NOT_MODIFIED)
.body(Body::empty())
.unwrap());
}
let len = meta.len();
let buf_size = optimal_buf_size(&meta);

let stream = file_stream(file, buf_size, len);
let body = Body::wrap_stream(stream.into_stream());
let mut response = http::Response::builder()
.status(StatusCode::OK)
.header(CONTENT_LENGTH, len)
.header(CONTENT_TYPE, mime_type.as_ref())
.header(CACHE_CONTROL, options.cache_control);

if let Some(etag) = entity_tag(&meta) {
response = response.header(ETAG, etag);
}
if let Some(content_encoding) = encoding {
response = response.header(CONTENT_ENCODING, content_encoding);
}

Ok(response.body(body).unwrap())
let response_future = File::open(path).and_then(|file| async move {
let meta = file.metadata().await?;
if not_modified(&meta, &headers) {
return Ok(http::Response::builder()
.status(StatusCode::NOT_MODIFIED)
.body(Body::empty())
.unwrap());
}
let len = meta.len();
let buf_size = optimal_buf_size(&meta);

let stream = file_stream(file, buf_size, len);
let body = Body::wrap_stream(stream.into_stream());
let mut response = http::Response::builder()
.status(StatusCode::OK)
.header(CONTENT_LENGTH, len)
.header(CONTENT_TYPE, mime_type.as_ref())
.header(CACHE_CONTROL, options.cache_control);

if let Some(etag) = entity_tag(&meta) {
response = response.header(ETAG, etag);
}
if let Some(content_encoding) = encoding {
response = response.header(CONTENT_ENCODING, content_encoding);
}

Ok(response.body(body).unwrap())
});

response_future
Expand Down

0 comments on commit d5d9fdf

Please sign in to comment.