Skip to content

Commit 9bafe50

Browse files
committed
unwrap ip address
1 parent 0380292 commit 9bafe50

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use actix_web::{get, App, HttpResponse, HttpServer, Responder, HttpRequest};
22

33
#[get("/")]
44
async fn hello(req: HttpRequest) -> impl Responder {
5-
let message = format!("hi! your ip: {:?}", req.peer_addr()) ;
5+
let address = req.peer_addr().unwrap().ip();
6+
let message = format!("hi! your ip: {:?}", address) ;
67
HttpResponse::Ok().body(message)
78
}
89

0 commit comments

Comments
 (0)