Skip to content

Commit ef97626

Browse files
committed
chore: added more endpoint and configured cargo.toml for library and testing
1 parent 1396c8e commit ef97626

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

8+
[lib]
9+
path = "src/lib.rs"
10+
11+
[[bin]]
12+
path = "src/main.rs"
13+
name = "robust-rust"
14+
815
[dependencies]
916
actix-web = "4"
1017
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

src/lib.rs

Whitespace-only changes.

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
1+
use actix_web::{web, App, HttpRequest, HttpServer, Responder, HttpResponse};
22

33
async fn greet(req: HttpRequest) -> impl Responder {
44
let name = req.match_info().get("name").unwrap_or("world");
55
format!("Hello {}!", name)
66
}
77

8+
async fn health_check() -> impl Responder {
9+
HttpResponse::Ok()
10+
}
11+
812
#[actix_web::main]
913
async fn main() -> std::io::Result<()> {
1014
HttpServer::new(|| {
1115
App::new()
1216
.route("/", web::get().to(greet))
1317
.route("/{name}", web::get().to(greet))
18+
.route("/health_check", web::get().to(health_check))
1419
})
1520
.bind(("127.0.0.1", 8080))?
1621
.run()

0 commit comments

Comments
 (0)