mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 18:44:35 +01:00
Add missing status code constructor methods on HttpResponse
(#3042)
This commit is contained in:
parent
d22c9f9fb1
commit
1040bc3d17
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
- Add `HttpServer::{bind, listen}_auto_h2c()` method behind new `http2` crate feature.
|
- Add `HttpServer::{bind, listen}_auto_h2c()` method behind new `http2` crate feature.
|
||||||
- Add `Resource::{get, post, etc...}` methods for more concisely adding routes that don't need additional guards.
|
- Add `Resource::{get, post, etc...}` methods for more concisely adding routes that don't need additional guards.
|
||||||
|
- Add several missing convenience methods on `HttpResponse` for their respective status codes.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ impl HttpResponse {
|
|||||||
NonAuthoritativeInformation,
|
NonAuthoritativeInformation,
|
||||||
StatusCode::NON_AUTHORITATIVE_INFORMATION
|
StatusCode::NON_AUTHORITATIVE_INFORMATION
|
||||||
);
|
);
|
||||||
|
|
||||||
static_resp!(NoContent, StatusCode::NO_CONTENT);
|
static_resp!(NoContent, StatusCode::NO_CONTENT);
|
||||||
static_resp!(ResetContent, StatusCode::RESET_CONTENT);
|
static_resp!(ResetContent, StatusCode::RESET_CONTENT);
|
||||||
static_resp!(PartialContent, StatusCode::PARTIAL_CONTENT);
|
static_resp!(PartialContent, StatusCode::PARTIAL_CONTENT);
|
||||||
static_resp!(MultiStatus, StatusCode::MULTI_STATUS);
|
static_resp!(MultiStatus, StatusCode::MULTI_STATUS);
|
||||||
static_resp!(AlreadyReported, StatusCode::ALREADY_REPORTED);
|
static_resp!(AlreadyReported, StatusCode::ALREADY_REPORTED);
|
||||||
|
static_resp!(ImUsed, StatusCode::IM_USED);
|
||||||
|
|
||||||
static_resp!(MultipleChoices, StatusCode::MULTIPLE_CHOICES);
|
static_resp!(MultipleChoices, StatusCode::MULTIPLE_CHOICES);
|
||||||
static_resp!(MovedPermanently, StatusCode::MOVED_PERMANENTLY);
|
static_resp!(MovedPermanently, StatusCode::MOVED_PERMANENTLY);
|
||||||
@ -42,10 +42,10 @@ impl HttpResponse {
|
|||||||
static_resp!(PermanentRedirect, StatusCode::PERMANENT_REDIRECT);
|
static_resp!(PermanentRedirect, StatusCode::PERMANENT_REDIRECT);
|
||||||
|
|
||||||
static_resp!(BadRequest, StatusCode::BAD_REQUEST);
|
static_resp!(BadRequest, StatusCode::BAD_REQUEST);
|
||||||
static_resp!(NotFound, StatusCode::NOT_FOUND);
|
|
||||||
static_resp!(Unauthorized, StatusCode::UNAUTHORIZED);
|
static_resp!(Unauthorized, StatusCode::UNAUTHORIZED);
|
||||||
static_resp!(PaymentRequired, StatusCode::PAYMENT_REQUIRED);
|
static_resp!(PaymentRequired, StatusCode::PAYMENT_REQUIRED);
|
||||||
static_resp!(Forbidden, StatusCode::FORBIDDEN);
|
static_resp!(Forbidden, StatusCode::FORBIDDEN);
|
||||||
|
static_resp!(NotFound, StatusCode::NOT_FOUND);
|
||||||
static_resp!(MethodNotAllowed, StatusCode::METHOD_NOT_ALLOWED);
|
static_resp!(MethodNotAllowed, StatusCode::METHOD_NOT_ALLOWED);
|
||||||
static_resp!(NotAcceptable, StatusCode::NOT_ACCEPTABLE);
|
static_resp!(NotAcceptable, StatusCode::NOT_ACCEPTABLE);
|
||||||
static_resp!(
|
static_resp!(
|
||||||
@ -57,13 +57,18 @@ impl HttpResponse {
|
|||||||
static_resp!(Gone, StatusCode::GONE);
|
static_resp!(Gone, StatusCode::GONE);
|
||||||
static_resp!(LengthRequired, StatusCode::LENGTH_REQUIRED);
|
static_resp!(LengthRequired, StatusCode::LENGTH_REQUIRED);
|
||||||
static_resp!(PreconditionFailed, StatusCode::PRECONDITION_FAILED);
|
static_resp!(PreconditionFailed, StatusCode::PRECONDITION_FAILED);
|
||||||
static_resp!(PreconditionRequired, StatusCode::PRECONDITION_REQUIRED);
|
|
||||||
static_resp!(PayloadTooLarge, StatusCode::PAYLOAD_TOO_LARGE);
|
static_resp!(PayloadTooLarge, StatusCode::PAYLOAD_TOO_LARGE);
|
||||||
static_resp!(UriTooLong, StatusCode::URI_TOO_LONG);
|
static_resp!(UriTooLong, StatusCode::URI_TOO_LONG);
|
||||||
static_resp!(UnsupportedMediaType, StatusCode::UNSUPPORTED_MEDIA_TYPE);
|
static_resp!(UnsupportedMediaType, StatusCode::UNSUPPORTED_MEDIA_TYPE);
|
||||||
static_resp!(RangeNotSatisfiable, StatusCode::RANGE_NOT_SATISFIABLE);
|
static_resp!(RangeNotSatisfiable, StatusCode::RANGE_NOT_SATISFIABLE);
|
||||||
static_resp!(ExpectationFailed, StatusCode::EXPECTATION_FAILED);
|
static_resp!(ExpectationFailed, StatusCode::EXPECTATION_FAILED);
|
||||||
|
static_resp!(ImATeapot, StatusCode::IM_A_TEAPOT);
|
||||||
|
static_resp!(MisdirectedRequest, StatusCode::MISDIRECTED_REQUEST);
|
||||||
static_resp!(UnprocessableEntity, StatusCode::UNPROCESSABLE_ENTITY);
|
static_resp!(UnprocessableEntity, StatusCode::UNPROCESSABLE_ENTITY);
|
||||||
|
static_resp!(Locked, StatusCode::LOCKED);
|
||||||
|
static_resp!(FailedDependency, StatusCode::FAILED_DEPENDENCY);
|
||||||
|
static_resp!(UpgradeRequired, StatusCode::UPGRADE_REQUIRED);
|
||||||
|
static_resp!(PreconditionRequired, StatusCode::PRECONDITION_REQUIRED);
|
||||||
static_resp!(TooManyRequests, StatusCode::TOO_MANY_REQUESTS);
|
static_resp!(TooManyRequests, StatusCode::TOO_MANY_REQUESTS);
|
||||||
static_resp!(
|
static_resp!(
|
||||||
RequestHeaderFieldsTooLarge,
|
RequestHeaderFieldsTooLarge,
|
||||||
@ -83,6 +88,11 @@ impl HttpResponse {
|
|||||||
static_resp!(VariantAlsoNegotiates, StatusCode::VARIANT_ALSO_NEGOTIATES);
|
static_resp!(VariantAlsoNegotiates, StatusCode::VARIANT_ALSO_NEGOTIATES);
|
||||||
static_resp!(InsufficientStorage, StatusCode::INSUFFICIENT_STORAGE);
|
static_resp!(InsufficientStorage, StatusCode::INSUFFICIENT_STORAGE);
|
||||||
static_resp!(LoopDetected, StatusCode::LOOP_DETECTED);
|
static_resp!(LoopDetected, StatusCode::LOOP_DETECTED);
|
||||||
|
static_resp!(NotExtended, StatusCode::NOT_EXTENDED);
|
||||||
|
static_resp!(
|
||||||
|
NetworkAuthenticationRequired,
|
||||||
|
StatusCode::NETWORK_AUTHENTICATION_REQUIRED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user