add responder for unit

This commit is contained in:
Akos Vandra 2021-10-01 01:17:35 +02:00
parent a3806cde19
commit 0c4b8e138c
2 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,7 @@
## Unreleased - 2021-xx-xx
### Added
* Option to allow `Json` extractor to work without a `Content-Type` header present. [#2362]
* Implemented responder for `()` to respond with `204 No Content`
### Changed
* Associated type `FromRequest::Config` was removed. [#2233]

View File

@ -116,6 +116,12 @@ impl<T: Responder> Responder for (T, StatusCode) {
}
}
impl Responder for () {
fn respond_to(self, req: &HttpRequest) -> HttpResponse {
HttpResponse::new(StatusCode::NO_CONTENT)
}
}
macro_rules! impl_responder {
($res: ty, $ct: path) => {
impl Responder for $res {