Compare commits

..

No commits in common. "32f0ed27a7947e9631d2e0d9f853e1b280283455" and "bf627f60035d90cc2b48ed42aaef7843ef772169" have entirely different histories.

3 changed files with 30 additions and 23 deletions

View file

@ -6,20 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
# Compiling actix-server v2.2.0
# Compiling actix-http v3.3.1
# Compiling actix-web v4.3.1
actix-web ="4" actix-web ="4"
utoipa = { version = "3", features = ["actix_extras"] }
# Compiling actix-rt v2.8.0
actix-rt = "*"
#actix-swagger = "*"
serde = "*"
#utoipa = { version = "3", features = ["actix_extras"] }
# Compiling utoipa-swagger-ui v3.1.4
utoipa-swagger-ui = { version = "3", features = ["actix-web"] }
[[bin]] [[bin]]
name = "webserver" name = "webserver"
path = "main.rs" path = "web.rs"

View file

@ -1,10 +0,0 @@
HttpServer::new(move || {
App::new()
.service(
SwaggerUi::new("/swagger-ui/{_:.*}")
.url("/api-docs/openapi.json", ApiDoc::openapi()),
)
})
.bind((Ipv4Addr::UNSPECIFIED, 8000)).unwrap()
.run();

28
backend/web.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", 8080))?
.run()
.await
}