File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,4 +19,4 @@ serde_json = "1.0.91"
1919reqwest = { version = " 0.12.14" , features = [" json" ] }
2020rpassword = " 7.4.0"
2121rust-argon2 = " 3.0.0"
22- tracing = " 0.1.41"
22+ tracing = " 0.1.41"
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ use crate::routes::create_invite_codes::create_invite_codes_handler;
1414use crate :: routes:: disable_invite_codes:: disable_invite_codes_handler;
1515use crate :: routes:: generate_otp:: generate_otp_handler;
1616use crate :: routes:: get_invite_codes:: get_invite_codes_handler;
17+ use crate :: routes:: health:: healthcheck_handler;
1718use crate :: routes:: login:: login_user;
1819use crate :: routes:: validate_otp:: validate_otp_handler;
1920use crate :: routes:: verify_otp:: verify_otp_handler;
@@ -121,6 +122,7 @@ async fn main() -> io::Result<()> {
121122 ) )
122123 . app_data ( Data :: new ( db_pool. clone ( ) ) )
123124 . app_data ( Data :: new ( config. clone ( ) ) )
125+ . service ( healthcheck_handler)
124126 . service ( login_user)
125127 . service ( generate_otp_handler)
126128 . service ( verify_otp_handler)
Original file line number Diff line number Diff line change 1+ use actix_web:: { HttpResponse , Responder , get} ;
2+
3+ #[ get( "/health" ) ]
4+ pub async fn healthcheck_handler ( ) -> impl Responder {
5+ HttpResponse :: Ok ( ) . message_body ( "ok" )
6+ }
7+
8+ #[ cfg( test) ]
9+ mod tests {
10+ use actix_web:: { App , body:: MessageBody , test} ;
11+
12+ use super :: * ;
13+
14+ #[ actix_web:: test]
15+ async fn test_healthcheck_get ( ) {
16+ let app = test:: init_service ( App :: new ( ) . service ( healthcheck_handler) ) . await ;
17+ let req = test:: TestRequest :: get ( ) . uri ( "/health" ) . to_request ( ) ;
18+ let resp = test:: call_service ( & app, req) . await ;
19+ assert ! ( resp. status( ) . is_success( ) ) ;
20+ assert ! ( resp. into_body( ) . try_into_bytes( ) . unwrap( ) == "ok" ) ;
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ pub mod create_invite_codes;
88pub mod disable_invite_codes;
99pub mod generate_otp;
1010pub mod get_invite_codes;
11+ pub mod health;
1112pub mod login;
1213pub mod validate_otp;
1314pub mod verify_otp;
You can’t perform that action at this time.
0 commit comments