1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-18 11:55:36 +02:00

[actix-files] Allow user defined guards for NamedFile (actix#1113) (#1115)

* [actix-files] remove request method checks from NamedFile

* [actix-files] added custom guard checks to FilesService

* [actix-files] modify method check tests (NamedFile -> Files)

* [actix-files] add test for custom guards in Files

* [actix-files] update changelog
This commit is contained in:
Naim A
2019-10-08 07:09:40 +03:00
committed by Nikolay Kim
parent 0f09415469
commit 4de2e8a898
3 changed files with 72 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ use actix_http::body::SizedStream;
use actix_web::http::header::{
self, ContentDisposition, DispositionParam, DispositionType,
};
use actix_web::http::{ContentEncoding, Method, StatusCode};
use actix_web::http::{ContentEncoding, StatusCode};
use actix_web::middleware::BodyEncoding;
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
@@ -324,16 +324,6 @@ impl Responder for NamedFile {
return Ok(resp.streaming(reader));
}
match *req.method() {
Method::HEAD | Method::GET => (),
_ => {
return Ok(HttpResponse::MethodNotAllowed()
.header(header::CONTENT_TYPE, "text/plain")
.header(header::ALLOW, "GET, HEAD")
.body("This resource only supports GET and HEAD."));
}
}
let etag = if self.flags.contains(Flags::ETAG) {
self.etag()
} else {