webserver_colin_ugo/http/
status.rs1pub struct StatusCode;
3
4impl StatusCode {
5 pub const OK: &'static str = "HTTP/1.1 200 OK";
7
8 pub const BAD_REQUEST: &'static str = "HTTP/1.1 400 Bad Request";
10 pub const FORBIDDEN: &'static str = "HTTP/1.1 403 Forbidden";
11 pub const NOT_FOUND: &'static str = "HTTP/1.1 404 Not Found";
12 pub const METHOD_NOT_ALLOWED: &'static str = "HTTP/1.1 405 Method Not Allowed";
13
14 pub const INTERNAL_SERVER_ERROR: &'static str = "HTTP/1.1 500 Internal Server Error";
16 pub const NOT_IMPLEMENTED: &'static str = "HTTP/1.1 501 Not Implemented";
17 pub const HTTP_VERSION_NOT_SUPPORTED: &'static str = "HTTP/1.1 505 HTTP Version Not Supported";
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn test_status_codes() {
26 assert_eq!(StatusCode::OK, "HTTP/1.1 200 OK");
27 assert_eq!(StatusCode::BAD_REQUEST, "HTTP/1.1 400 Bad Request");
28 assert_eq!(StatusCode::FORBIDDEN, "HTTP/1.1 403 Forbidden");
29 assert_eq!(StatusCode::NOT_FOUND, "HTTP/1.1 404 Not Found");
30 assert_eq!(StatusCode::METHOD_NOT_ALLOWED, "HTTP/1.1 405 Method Not Allowed");
31 assert_eq!(StatusCode::INTERNAL_SERVER_ERROR, "HTTP/1.1 500 Internal Server Error");
32 assert_eq!(StatusCode::NOT_IMPLEMENTED, "HTTP/1.1 501 Not Implemented");
33 assert_eq!(StatusCode::HTTP_VERSION_NOT_SUPPORTED, "HTTP/1.1 505 HTTP Version Not Supported");
34 }
35}