actix boilerplate

This commit is contained in:
Aria 2025-03-14 17:47:42 +11:00
commit 7acc03218d
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
4 changed files with 1549 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1513
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

7
Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "remote-image-compression"
version = "0.1.0"
edition = "2024"
[dependencies]
actix-web = "4.10.2"

28
src/main.rs Normal file
View file

@ -0,0 +1,28 @@
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
async fn manual_hello() -> impl Responder {
HttpResponse::Ok().body("Hey there!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.service(echo)
.route("/hey", web::get().to(manual_hello))
})
.bind(("127.0.0.1", 3970))?
.run()
.await
}