Last active
October 13, 2022 19:37
-
-
Save ilopX/f95597235e3ed0b46fee52d28ad56203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use actix_web::{App, get, HttpResponse, HttpServer, post, Responder, web}; | |
#[actix_web::main] | |
async fn main() -> std::io::Result<()> { | |
println!("127.0.0.1:8080"); | |
println!("\t/"); | |
println!("\t/echo"); | |
println!("\t/txt"); | |
HttpServer::new(|| { | |
App::new() | |
.service(index) | |
.service(echo) | |
.service(txt) | |
}) | |
.bind(("127.0.0.1", 8080))? | |
.run() | |
.await | |
} | |
#[get("/")] | |
async fn index() -> impl Responder { | |
HttpResponse::Ok().body("index") | |
} | |
#[post("/echo")] | |
async fn echo(req_body: String) -> impl Responder { | |
HttpResponse::Ok().body("echo") | |
} | |
#[post("/txt")] | |
async fn txt(req_body: String) -> impl Responder { | |
HttpResponse::Ok().body("txt") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment