Add http status code 503

When we are not capable to provide a certain kind of service, but should be
after some delay. Http server is better to reply status code 503. It is more
suggestive per as to http spec.

```
The server is currently unable to handle the request due to a temporary
overload or scheduled maintenance, which will likely be alleviated after some delay.
```

Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
This commit is contained in:
Changwei Ge
2020-10-28 16:05:28 +08:00
committed by Alin Dima
parent 40309b72ee
commit 59ab64440a
2 changed files with 5 additions and 1 deletions

View File

@@ -1 +1 @@
{"coverage_score": 92.4, "exclude_path": "", "crate_features": ""}
{"coverage_score": 92.5, "exclude_path": "", "crate_features": ""}

View File

@@ -27,6 +27,8 @@ pub enum StatusCode {
InternalServerError,
/// 501, Not Implemented
NotImplemented,
/// 503, Service Unavailable
ServiceUnavailable,
}
impl StatusCode {
@@ -40,6 +42,7 @@ impl StatusCode {
StatusCode::NotFound => b"404",
StatusCode::InternalServerError => b"500",
StatusCode::NotImplemented => b"501",
StatusCode::ServiceUnavailable => b"503",
}
}
}
@@ -285,5 +288,6 @@ mod tests {
assert_eq!(StatusCode::NotFound.raw(), b"404");
assert_eq!(StatusCode::InternalServerError.raw(), b"500");
assert_eq!(StatusCode::NotImplemented.raw(), b"501");
assert_eq!(StatusCode::ServiceUnavailable.raw(), b"503");
}
}