Skip to content

Commit d7e7560

Browse files
committed
fix typos
1 parent 1e4b0dd commit d7e7560

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct User {
1515
email: String,
1616
}
1717

18-
const DB_URL: &str = !env("DATABASE_URL");
18+
const DB_URL: &str = env!("DB_URL");
1919
const RESPONSE_OK: &str = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n";
2020
const RESPONSE_NOT_FOUND: &str = "HTTP/1.1 404 NOT FOUND\r\n\r\n";
2121
const RESPONSE_INTERNAL_SERVER_ERROR: &str = "HTTP/1.1 500 INTERNAL SERVER ERROR\r\n\r\n";
@@ -50,12 +50,12 @@ fn handle_client(mut stream: TcpStream) {
5050
request.push_str(String::from_utf8_lossy(&buffer[..size]).as_ref());
5151

5252
let (status_line, content) = match &*request {
53-
r if request_with("POST /users") => handle_post_request(r),
54-
r if request_with("GET /users") => handle_get_request(r),
55-
r if request_with("GET /users") => handle_get_all_request(r),
56-
r if request_with("PUT /users") => handle_put_request(r),
57-
r if request_with("DELETE /users") => handle_delete_request(r),
58-
_ => (NOT_FOUND, "Not found".to_string()),
53+
r if r.starts_with("POST /users") => handle_post_request(r),
54+
r if r.starts_with("GET /users") => handle_get_request(r),
55+
r if r.starts_with("GET /users") => handle_get_all_request(r),
56+
r if r.starts_with("PUT /users") => handle_put_request(r),
57+
r if r.starts_with("DELETE /users") => handle_delete_request(r),
58+
_ => (RESPONSE_NOT_FOUND.to_string(), "Not found".to_string()),
5959
};
6060

6161
stream.write_all(format!("{}{}", status_line, content).as_bytes()).unwrap();

0 commit comments

Comments
 (0)