Skip to content

Instantly share code, notes, and snippets.

@ilopX
Last active October 13, 2022 19:37
Show Gist options
  • Save ilopX/f95597235e3ed0b46fee52d28ad56203 to your computer and use it in GitHub Desktop.
Save ilopX/f95597235e3ed0b46fee52d28ad56203 to your computer and use it in GitHub Desktop.
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