summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/routes.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/server/routes.rs b/src/server/routes.rs
new file mode 100644
index 0000000..aa8fa92
--- /dev/null
+++ b/src/server/routes.rs
@@ -0,0 +1,31 @@
+use axum::response::IntoResponse;
+
+pub async fn health_check() -> impl IntoResponse {
+ let name = env!("CARGO_PKG_NAME");
+ let ver = env!("CARGO_PKG_VERSION");
+
+ format!("{name} v{ver} is live")
+}
+
+#[cfg(test)]
+mod tests {
+ use axum::{
+ body::Body,
+ http::{Request, StatusCode},
+ };
+ use tower::ServiceExt;
+
+ use crate::server;
+
+ #[tokio::test]
+ async fn hello_world() {
+ let app = server::router();
+
+ let response = app
+ .oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
+ .await
+ .unwrap();
+
+ assert_eq!(response.status(), StatusCode::OK);
+ }
+}