forked from plabayo/rama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_health_check.rs
34 lines (32 loc) · 929 Bytes
/
http_health_check.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! An example to show how to create a minimal health check server,
//! using the [`HttpServer`] and [`Executor`] from Rama.
//!
//! [`HttpServer`]: crate::http::server::HttpServer
//! [`Executor`]: crate::rt::Executor
//!
//! This example will create a server that listens on `127.0.0.1:8080`.
//!
//! # Run the example
//!
//! ```sh
//! cargo run --example http_health_check
//! ```
//!
//! # Expected output
//!
//! The server will start and listen on `:8080`. You can use `curl` to check if the server is running:
//!
//! ```sh
//! curl -v http://127.0.0.1:8080
//! ```
//!
//! You should see a response with `HTTP/1.1 200 OK` and an empty body.
use rama::{http::server::HttpServer, rt::Executor, service::service_fn};
#[tokio::main]
async fn main() {
let exec = Executor::default();
HttpServer::auto(exec)
.listen("127.0.0.1:8080", service_fn(|| async move { Ok(()) }))
.await
.unwrap();
}