1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-18 03:45:33 +02:00

add wrap_fn to App and Scope

This commit is contained in:
Nikolay Kim
2019-03-25 13:43:02 -07:00
parent d30027ac5b
commit e18227cc3d
4 changed files with 282 additions and 26 deletions

View File

@@ -11,7 +11,9 @@ use bitflags::bitflags;
use mime;
use mime_guess::guess_mime_type;
use actix_web::http::header::{self, DispositionType, ContentDisposition, DispositionParam};
use actix_web::http::header::{
self, ContentDisposition, DispositionParam, DispositionType,
};
use actix_web::http::{ContentEncoding, Method, StatusCode};
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
@@ -311,13 +313,17 @@ impl Responder for NamedFile {
&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."));
.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 { None };
let etag = if self.flags.contains(Flags::ETAG) {
self.etag()
} else {
None
};
let last_modified = if self.flags.contains(Flags::LAST_MD) {
self.last_modified()
} else {